Next.js Discord

Discord Forum

Next firebase protected routes

Unanswered
xyw posted this in #help-forum
Open in Discord
Avatar
xywOP
I have a Nextjs project with chakra-ui recoil and react-firebase-hooks within. I have 3 routes at this moment.
* index.tsx ("/")
* login.tsx ("/login")
* finishsignup.tsx ("/finishsignup")
The code i currently have (on the picture) handles the protection of the routes and each route has the same code (obviously with different router.replaces), but I'm having issues with it.
1. It makes too many redirects that nothing renders.
2. I don't think it's that secure.
3. When I go to "/" without a user, it first renders (with no username or profile picture) and then redirects me to "/login".
Any suggestions on how to manage protected routes better, that works fast and is safe.
Image

0 Replies