You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When user session data is updated server-side (e.g., through Auth0 Actions, custom claims, or API operations), there's currently no straightforward way to refresh the client-side session cache in the @auth0/nextjs-auth0 v4 SDK. This leads to stale data being displayed to users until a full page refresh occurs.
Current Limitations
In applications with a hybrid server/client architecture using NextJS:
User attributes can be updated in Auth0 through Rules, Actions, or Management API
Custom session properties may be modified during middleware or server components
The client-side cache continues to serve outdated session data via useUser() hook
Users see inconsistent data between server-rendered and client-side components
This is particularly problematic in workflows where:
User completes an onboarding process that updates their profile
User gains or loses permissions that should immediately affect UI elements
User data is enriched from external systems after authentication
My Scenario
In my application, I updated the user profile in an /api/profile endpoint. This updates the basic user data in my database. Additionally, I updated the Auth0 user session using:
Hi @arealesramirez, while we are planning to release a fix for this shortly, can you try the following workaround:
import{useSWRConfig}from"swr";constMyComponent=()=>{const{ mutate }=useSWRConfig();constupdateProfile=()=>{// Update profile API call// On success:mutate("/auth/profile");}};
Please let us know if this solution works for your setup!
Checklist
Describe the problem you'd like to have solved
Problem Description
When user session data is updated server-side (e.g., through Auth0 Actions, custom claims, or API operations), there's currently no straightforward way to refresh the client-side session cache in the @auth0/nextjs-auth0 v4 SDK. This leads to stale data being displayed to users until a full page refresh occurs.
Current Limitations
In applications with a hybrid server/client architecture using NextJS:
This is particularly problematic in workflows where:
My Scenario
In my application, I updated the user profile in an /api/profile endpoint. This updates the basic user data in my database. Additionally, I updated the Auth0 user session using:
However, these changes are not reflected in the client-side session (
useUser()
) until a full page refresh or re-login.This creates a confusing user experience where parts of the UI reflect the updated state while others show outdated information.
Requested Feature
I request a mechanism to programmatically refresh the client-side session cache without requiring a full page reload.
Describe the ideal solution
Given the implementation of
useUser
hook leveraging SWR, I propose extending the useUser hook to expose SWR's revalidation capabilities:Alternatives and current workarounds
For now, my workaround in my code was to add the following import and use the
useSWRConfig
hookand refresh the cache of the request
/auth/profile
Additional context
No response
The text was updated successfully, but these errors were encountered: