Next.js Discord

Discord Forum

Refreshing authentication status on navbar

Unanswered
Mugger Crocodile posted this in #help-forum
Open in Discord
Original message was deleted.

38 Replies

" I use a server action that redirects the user to the dashboard when successful, but fails to update the session UI data"

did u try calling refresh()?
after everything is done in server action
did u use unstable_cache or "use cache"?
can you send which files are relevant to the issue?
Mugger Crocodile
I tried calling refresh(), yes
‘Use cache’
@Mugger Crocodile ‘Use cache’
i need more information, such as how you read the session and how you set the sesison
Mugger Crocodile
Just a minute
This is the login sserver action
whats inside authClient?
you need to do debugging
console.log at each part of the getCurrentUser to see what went wrong
why it returned null
Mugger Crocodile
It is an instance of a custom package of mine, which for sure works
to handle authentication with JWT
Because I console.log the output of the function, and returns the correct value in the console, but does not update the UI
this is weird. can you reproduce it in a minimal repository?
Mugger Crocodile
I will try to do it
Mugger Crocodile
So I just tried doing it, and looks like the problem is with cacheComponents
I obviously had to try it out when it became stable in this version
Mugger Crocodile
Based on what I saw, it was prerendering the navigation bar
as soon as i disable cache components, it works just fine
@alfonsüs ardani this is weird. can you reproduce it in a minimal repository?
Mugger Crocodile
i reproduced it in a minimal repository too
even though "SessionContainer" is supposed to be dynamic, react is prerendering it for some reason
This is after prepending my component code with await connection()
Looks like cacheComponents still has a lot of stuff to work on
Curious to see how that is possible
hard to imagine how you did it
Mugger Crocodile
@Mugger Crocodile Click to see attachment
Mugger Crocodile
also I completely removed the cache() wrapper function from here. apparently that has caused problems too
thats weird. can you make a minimal reproduction repository?
its really hard to debug since you used custom packages and im not sure whats inside of those thats causing it to misbehave
Mugger Crocodile
Yes for sure
Mugger Crocodile
Mugger Crocodile
@alfonsüs ardani were you able to try it?