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
{{ message }}
This repository was archived by the owner on Jun 15, 2026. It is now read-only.
When a user is logged in and reopens the application in a new tab (or refreshes), the application briefly initializes with an unauthenticated state (signed: false). Because the authentication check is performed asynchronously in a useEffect hook, the router initially uses the "not signed in" route configuration. This causes immediate redirects to the login page or landing page, even if a valid session exists in localStorage.
Technical Requirements
Add loading state to AuthContext: Introduce a boolean state (e.g., loading or initializing) in AuthContext that defaults to true.
Update AuthProvider: Set loading to false only after checkCurrentAuthUser (or the initial session fetch) completes.
Update App.tsx:
While loading is true, display a loading spinner or a blank screen instead of the RouterProvider.
Ensure that the router configuration is only determined and rendered after the initial authentication check is complete.
Preserve Destination: Ensure that if a user is redirected to a protected route, the application waits for the auth check before deciding whether to allow access or redirect to login.
Acceptance Criteria
As a logged-in user, when I close the tab and reopen it at /home, I should see the dashboard/home page directly, without being redirected to the login page.
The application should show a consistent loading state (if needed) while verifying the session.
Unauthenticated users should still be redirected to the login page after the check fails.
Description
When a user is logged in and reopens the application in a new tab (or refreshes), the application briefly initializes with an unauthenticated state (
signed: false). Because the authentication check is performed asynchronously in auseEffecthook, the router initially uses the "not signed in" route configuration. This causes immediate redirects to the login page or landing page, even if a valid session exists in localStorage.Technical Requirements
loadingstate toAuthContext: Introduce a boolean state (e.g.,loadingorinitializing) inAuthContextthat defaults totrue.AuthProvider: Setloadingtofalseonly aftercheckCurrentAuthUser(or the initial session fetch) completes.App.tsx:loadingistrue, display a loading spinner or a blank screen instead of theRouterProvider.Acceptance Criteria
/home, I should see the dashboard/home page directly, without being redirected to the login page.