Skip to content

feat: Auth Initializer Component and App Providers#517

Merged
yusuftomilola merged 1 commit intoDistinctCodes:mainfrom
Mkalbani:feat/auth-initializer-providers
Feb 25, 2026
Merged

feat: Auth Initializer Component and App Providers#517
yusuftomilola merged 1 commit intoDistinctCodes:mainfrom
Mkalbani:feat/auth-initializer-providers

Conversation

@Mkalbani
Copy link
Contributor

Bootstrap the application with global providers and ensure authentication state is hydrated before any protected page renders.

Changes

  • AuthInitializer component: Calls useAuthStore.getState().initialize() on mount
  • providers.tsx: Wraps app in QueryClientProvider + AuthInitializer
  • auth.store.ts: Added initialize() method (runs once, sets isInitialized flag)
  • middleware.ts: Full redirect logic:
    • //dashboard
    • Unauthenticated /dashboard/*/login
    • Authenticated /login or /register/dashboard

Closes #448

- Add initialize() method to auth store (runs once on app boot)
- Create AuthInitializer component that hydrates auth state on mount
- Include AuthInitializer in providers.tsx
- Update middleware: redirect / → /dashboard
- Update middleware: unauthenticated /dashboard/* → /login
- Update middleware: authenticated /login|/register → /dashboard

Closes DistinctCodes#448
@vercel
Copy link

vercel bot commented Feb 25, 2026

@Mkalbani is attempting to deploy a commit to the naijabuz's projects Team on Vercel.

A member of the Team first needs to authorize it.

@yusuftomilola yusuftomilola merged commit 56fda04 into DistinctCodes:main Feb 25, 2026
3 of 5 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.

[Frontend] Create Auth Initializer Component and App Providers

2 participants