Next.js Discord

Discord Forum

How do I make the whole website aware when the user is logged in ?

Answered
Sun bear posted this in #help-forum
Open in Discord
Sun bearOP
Currently, after I log-in successfully, I can go back to the log-in page and do it again and again. My other components such as the top navigation bar are also not aware when a user is already logged in so they still display the log-in or create an account button.

Normally once a user is logged in the whole website and all components should be able to be aware of that, and pages such as sign-up and log-in should not longer be accessible by that user.

I'm a beginner and I just finished implementing my authentication logic so I don't know what to do next to solve this situation. This is for a consumer product so I'd like to fix this situation properly.

So what should I do about this ?
Answered by English Angora
You can protect your routes with middleware
View full answer

6 Replies

English Angora
You can protect your routes with middleware
Answer
@English Angora You can protect your routes with middleware
Sun bearOP
Thank you very much for your help.
English Angora
I think this is not a complete answer because i don't know which authentication startegy you are using
I am currently using Supabase for auth but someone advised me to use Clerk instead.
It's quite complicated to integrate cause I want to keep my custom links and UI but they are helping me out with this process and hopefully we'll manage to do it.