dynamic home page
Unanswered
Knopper gall posted this in #help-forum
Knopper gallOP
Hello everyone. I need some help on how to achieve a dynamic root page.
I am new to NextJs 13 and I am trying to figure out how to make a dynamic root page where if the user is logged in, it will render the dashboard page else if not then it will render the sign in page
here's the idea i did on react
<Router>
<Routes>
{/* Route for the home page when the user is logged in /}
<Route path="/home" element={isLoggedIn ? <Home /> : <Navigate to="/login" />} />
{/ Route for the login page when the user is logged out /}
<Route path="/login" element={!isLoggedIn ? <Login /> : <Navigate to="/home" />} />
{/ Redirect to the appropriate route based on the user's authentication status /}
<Route path="/" element={<Navigate to={isLoggedIn ? '/home' : '/login'} />} />
{/ Add other routes here for different pages */}
</Routes>
</Router>
that's the gist of it but I know on nextjs13 there is no routes anymore
I am new to NextJs 13 and I am trying to figure out how to make a dynamic root page where if the user is logged in, it will render the dashboard page else if not then it will render the sign in page
here's the idea i did on react
<Router>
<Routes>
{/* Route for the home page when the user is logged in /}
<Route path="/home" element={isLoggedIn ? <Home /> : <Navigate to="/login" />} />
{/ Route for the login page when the user is logged out /}
<Route path="/login" element={!isLoggedIn ? <Login /> : <Navigate to="/home" />} />
{/ Redirect to the appropriate route based on the user's authentication status /}
<Route path="/" element={<Navigate to={isLoggedIn ? '/home' : '/login'} />} />
{/ Add other routes here for different pages */}
</Routes>
</Router>
that's the gist of it but I know on nextjs13 there is no routes anymore