Next.js Discord

Discord Forum

Refreshing authentication status on navbar

Unanswered
Orinoco 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?
Orinoco Crocodile
I tried calling refresh(), yes
‘Use cache’
@Orinoco Crocodile ‘Use cache’
i need more information, such as how you read the session and how you set the sesison
Orinoco 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
Orinoco 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?
Orinoco Crocodile
I will try to do it
Orinoco 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
Orinoco Crocodile
Based on what I saw, it was prerendering the navigation bar
as soon as i disable cache components, it works just fine
@ᴉuɐpɹɐɐ this is weird. can you reproduce it in a minimal repository?
Orinoco 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
Orinoco Crocodile
@Orinoco Crocodile Click to see attachment
Orinoco 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
Orinoco Crocodile
Yes for sure
Orinoco Crocodile
Orinoco Crocodile
@ᴉuɐpɹɐɐ were you able to try it?