Skip to content
This repository was archived by the owner on Jun 15, 2026. It is now read-only.
This repository was archived by the owner on Jun 15, 2026. It is now read-only.

[Bug] Home page not loading after closing and reopening the tab while logged in #44

Description

@RMCampos

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 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

  1. Add loading state to AuthContext: Introduce a boolean state (e.g., loading or initializing) in AuthContext that defaults to true.
  2. Update AuthProvider: Set loading to false only after checkCurrentAuthUser (or the initial session fetch) completes.
  3. 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.
  4. 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

  1. 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.
  2. The application should show a consistent loading state (if needed) while verifying the session.
  3. Unauthenticated users should still be redirected to the login page after the check fails.

Metadata

Metadata

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions