React hide code from sources by lazy loading

73 Views Asked by At

Is it possible to have a portion of my code not visible in the sources tab of the developer tools at all, until the user logs in. I know about not deploying source maps, but in theory that can still be reverse engineered. Or do I need to implement this as two apps, one as a "login app", and the other one as "private-app". The app is client side rendered (with react).

Could this work?

const LazyPrivateRoutes = lazy(() => import('./PrivateRoutes'));

// function component

const isLoggedIn = useSelector(AuthSelectors.isLoggedIn);

return (
 <Suspense fallback={<></>}>
   <BrowserRouter>
     <Switch>
      {isLoggedIn && <LazyPrivateRoutes />}
      <PublicRoute
        path={routes.login}
        component={<LoginPage />}
        isAuthenticated={isLoggedIn}
        />
     </Switch>
   </BrowserRouter>
 </Suspense>
)
0

There are 0 best solutions below