Next.js Discord

Discord Forum

How to track user login in next auth for rendering button

Unanswered
Eyebrowed Thrush posted this in #help-forum
Open in Discord
Eyebrowed ThrushOP
As I found next auth provides ways of tracking the user authentication

useSession (Client based )
getServerSession(authOptions) Server Based
Now let's suppose I want to render the login and logout buttons based on the user's state if I use clientside method it shows loading for a moment (I can't know what is client's current status is)

Then I started using getServerSession the problem is I am facing is: I have roles for my users like User, student, and teacher Now if update that role using the update trigger in auth options it only appears after another reload

Now I want to know is any way that there should be no delay while knowing the client login status and also I can update the information at the time. Thanks

More importantly, what do you use personally?

I am using jwt login from backend. ( i am open to have new ideas like other alternatives of next auth)

0 Replies