Skip to content

[FE-03] Fix race condition in Zustand auth hydration - #303

Merged
Leothosine merged 2 commits into
tosirano:mainfrom
mftee:fix/fe-03-zustand-hydration-race
Jul 20, 2026
Merged

[FE-03] Fix race condition in Zustand auth hydration#303
Leothosine merged 2 commits into
tosirano:mainfrom
mftee:fix/fe-03-zustand-hydration-race

Conversation

@mftee

@mftee mftee commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Changes

  • Add _hasHydrated field to auth store with onRehydrateStorage callback
  • Create useAuthRehydrated() hook for hydration state access
  • Add ProtectedRoute component with skeleton loader during hydration
  • Remove need for setTimeout in auth initialization

Acceptance Criteria

  • No protected content is visible before the auth check completes
  • Full-screen skeleton renders during hydration
  • _hasHydrated resolves correctly on cold start, page refresh, and back-navigation
  • No setTimeout or arbitrary delay remains in auth initialization code

closes #271

- Add _hasHydrated field to auth store with onRehydrateStorage callback
- Create useAuthRehydrated hook for hydration state access
- Add ProtectedRoute component with skeleton loader during hydration
- Remove need for setTimeout in auth initialization
@mftee
mftee force-pushed the fix/fe-03-zustand-hydration-race branch from 68787ff to d323d97 Compare July 16, 2026 17:40

@Leothosine Leothosine left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Leothosine
Leothosine merged commit 0258262 into tosirano:main Jul 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FE-03] Fix race condition in Zustand auth hydration causing flash of protected content

2 participants