Skip to content

Navbar auth flash: lift auth state to context #20

@emares17

Description

@emares17

Problem

Auth state is local to Navbar, so isAuthenticated initializes to false on every mount. Before the /auth/status check resolves, authenticated users briefly see the logged-out nav (Features, How It Works, Help) instead of Dashboard/Logout.

This is caused by network latency on the auth check — sometimes imperceptible, sometimes noticeable (especially after Railway cold starts).

Proposed Fix

Lift auth state into a React Context (AuthContext) that wraps the app:

  • Run the /auth/status check once on app boot, not on every Navbar mount
  • Seed initial state from localStorage so the first render is correct with no loading gate
  • Navbar reads from context via useContext(AuthContext) — no local state, no local effect
  • Logout updates shared context so all consumers reflect the change immediately

This also unblocks protected routes from sharing auth state without redundant checks.

Notes

Deferred intentionally — will be addressed alongside upcoming context/auth refactor.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions