auth0 / nextjs-auth0

Next.js SDK for signing in with Auth0

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using Auth0 methods on a Server Action causes a flickering on the NextJS Client

julianv97 opened this issue · comments

Checklist

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

  1. Create a use cliente component.
  2. Create a server action.
  3. Add logic to retrieve the Auth0 access token on the server action.
  4. Call to the server action on the use client component.
  5. 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 :(