Theo's Typesafe CultTTC
Theo's Typesafe Cult3y ago
54 replies
Theia

Protected routes in Nextjs?

In the past I have made protected routes using react router so that if a user is not authenticated and tries to go to a page, they are redirected to the login page and then once logged in, brought to the page they were trying to go. I’m now trying to learn Nextjs and wanna know firstly if this is the best way to ensure authentication, and also the best way to do it with Nextjs routing if it is. I’ve found varying answers online so I figured I’d ask here.
Was this page helpful?