stytchauth/stytch-nextjs-app-router-example

User loading issue

germanamz opened this issue · 1 comments

When loading a session from a subdomain useStytchUser has not finished loading the user but its isInitialized flag is true and the user prop is null. This makes harder to detect when the user is actually authenticated or not. I believe adding a isLoading flag will be helpful for these situations.

Example:

Having two apps,
A) The Authentication app that handles stytch flows
B) The business logic app

Steps:

  1. App B redirect to App A to authenticate
  2. App A authenticates the user and redirects back to App B
  3. When stytch is loading isInitialized first is false after some time it changes to true but user is still null.

Log format: label, userData, isInitialized
image

This only happens one time after authentication