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.
Problem
Auth state is local to
Navbar, soisAuthenticatedinitializes tofalseon every mount. Before the/auth/statuscheck 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:/auth/statuscheck once on app boot, not on every Navbar mountlocalStorageso the first render is correct with no loading gateuseContext(AuthContext)— no local state, no local effectThis also unblocks protected routes from sharing auth state without redundant checks.
Notes
Deferred intentionally — will be addressed alongside upcoming context/auth refactor.