Auth0-nextjs V4 migration: How to update session with new claims after logged in

We are looking to migrate from v3 to v4 of the nextjs SDK in order to update to nextjs15 and are mostly working but running into an issue.

During our signup process we interrupt the signup flow to gather more information from the user. To work out if we need to do this the BE is attaching claims to the JWT that describe the current user state. To get these we modified the beforeSessionSavedconfig to return all session information into the session, great!

The part we are having trouble with is that after the user completes the onboarding step we need to re-fetch a new access token to update the claims and let our user proceed through. We used to do this by redirecting the user to /api/auth/silent-login after each step which would do a refresh and fetch new claims. Since this has been removed we cannot find a way to update the claims on-demand.

I have tried going down the route of using updateSession() but this doesn’t actually do a new login to fetch new claims it just allows you to append data. We do not want to append the claims ourselves as the back-end should always be the source of truth here.

How would we go about solving this issue?

Hi @lex.webb,

Welcome to the Auth0 Community and thank you for your post!

My recommendation on how to achieve this behavior on the server would be utilizing the getSession() helper that can be used in Server Components, Server Routes, and Server Actions to get the session of the currently authenticated user.

Multiple example can be checked out here under our github documentation.

After checking if the session exists you can initiate silent authentication by redirecting the user to the /authorize endpoint with prompt=none.

I hope this helps, so you can let me know if this does the trick for you.
Thanks,
Remus