Skip to content

[Frontend] Create Auth Initializer Component and App Providers #448

@yusuftomilola

Description

@yusuftomilola

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

Requirements

providers.tsx — Wraps the app in:

  • QueryClientProvider (React Query)
  • Any other global providers

AuthInitializer component — A use client component that calls useAuthStore.getState().initialize() on mount using useEffect. Must be included in the root layout so it runs on every page load.

Middleware (middleware.ts) — Next.js edge middleware that:

  • Checks for the isAuthenticated cookie
  • Redirects //dashboard
  • Redirects unauthenticated users from /(dashboard)/* routes to /login
  • Redirects authenticated users away from /(auth)/* routes to /dashboard

Acceptance Criteria

  • initialize() runs once on app boot
  • Unauthenticated access to /dashboard redirects to /login
  • Authenticated access to /login redirects to /dashboard

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions