Using Auth0 methods on a Server Action causes a flickering on the NextJS Client
julianv97 opened this issue · comments
Checklist
- The issue can be reproduced in the nextjs-auth0 sample app (or N/A).
- I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
- I have looked into the API documentation and have not found a suitable solution or answer.
- I have searched the issues and have not found a suitable solution or answer.
- I have searched the Auth0 Community forums and have not found a suitable solution or answer.
- I agree to the terms within the Auth0 Code of Conduct.
Description
We want to call a third party API through a server on a use client
component and we need to send the Auth0 access token to that API.
When we call to getSession()
or getAccessToken()
inside that server action all the client have a flickering since the entire document along with the CSS and the fonts we use are reloaded again. If we don't use anything from Auth0 on that server action we don't have that flickering
Screen.Recording.2024-01-24.at.00.09.39.mov
Reproduction
- Create a use cliente component.
- Create a server action.
- Add logic to retrieve the Auth0 access token on the server action.
- Call to the server action on the use client component.
- There is the flickering and all the files reloaded.
Additional context
No response
nextjs-auth0 version
3.5.0
Next.js version
14.0.4
Node.js version
18.x
I'm seeing the same, if i remove the auth0 code the response from the server action is tiny, with the auth0 code it returns a much larger response. almost looks like it's returning the entire page.
The flickering probably happens because the css is downloaded and applied again.
Same issue here, I digged a bit and it is caused by Next.js invalidating path whenever a cookie is set, which auth0 basically do whenever you call getSession I guess to refresh the session cookie
Next.js related issue here: vercel/next.js#50163
On my side it's making our form unusable as it is, forces us to us API/fetch instead of actions and will probably make me pull out of Auth0 in the long run :(