When the profile widget is open, refreshing the pa...
# ask-a-descoper
a
When the profile widget is open, refreshing the page (F5 or browser refresh) causes all displayed values to become
null
and show as
Unverified
. Steps to Reproduce Log in and open the profile widget. Observe values are present and verified. Press F5 or click the browser refresh button. 1. After reload, the profile widget shows
null
values and
Unverified
status.
✅ 1
d
Session Token Issue This happens because the profile widget loses access to the session token after a browser refresh. The session token is likely stored in memory or local storage and gets cleared during the refresh. Check Token Storage Configuration Verify your SDK configuration for token persistence:
Copy code
<AuthProvider
  projectId="your-project-id"
  persistTokens={true}
  sessionTokenViaCookie={true}
  autoRefresh={true}
>
Implement Session Recovery Add session validation on page load to restore the user state:
Copy code
import { useDescope, useSession } from '@descope/react-sdk'
const ProfileWidget = () => {
  const { isAuthenticated, isSessionLoading } = useSession()
  const { refresh } = useDescope()
  useEffect(() => {
    if (!isAuthenticated && !isSessionLoading) {
      // Attempt to refresh session if refresh token exists
      refresh().catch(() => {
        // Handle failed refresh - redirect to login
      })
    }
  }, [isAuthenticated, isSessionLoading])
  if (isSessionLoading) return <div>Loading...</div>
  if (!isAuthenticated) return <div>Please log in</div>
  return <ProfileComponent />
}
• Set
persistTokens={true}
to store tokens in browser storage • Use
sessionTokenViaCookie={true}
for better persistence across refreshes • Enable
autoRefresh={true}
to automatically refresh expired sessions OAuth with Client SDK | Descope Documentation