How mwanga45/nextjs-toolkit works
Next Toolkit is a frontend-only Next.js foundation for applications backed by an external REST API. The main workflow is users submitting validated login or registration forms, server actions calling auth endpoints, and successful tokens being stored in secure cookies before navigation. Protected dashboard access verifies the session and role; refresh and proxy handlers support ongoing API access. The README also documents password recovery, email verification, typed API boundaries, and client-side user state. The graph uses documented capabilities where source was not sampled; unsampled relationships are omitted.
Main entry points: auth-actions.ts Auth actions · page.tsx Auth routes · session.ts Session access · client.ts Typed API client
Components 21
Application experience
- Auth routes
src/app/(auth)/login/page.tsx - Login form
src/features/auth/components/login-form.tsx - Registration form
src/features/auth/components/register-form.tsx - Email verification
src/app/(auth)/verify-email/verify-email-status.tsx - Dashboard
src/app/(dashboard)/dashboard/page.tsx - Role gate
src/components/shared/role-gate.tsx - Query provider
src/providers/query-provider.tsx
Authentication
- User state hook
src/features/auth/hooks/use-user.ts - Auth actions
src/features/auth/actions/auth-actions.ts - Auth schemas
src/features/auth/schemas/auth.ts - Auth API
src/features/auth/api/auth-api.ts
Session security
- Session access
src/lib/auth/session.ts - JWT verification
src/lib/session/jwt.ts - Session cookies
src/lib/session/cookies.ts - Token refresh
src/lib/session/refresh.ts - Refresh handler
src/app/api/auth/refresh/route.ts - Route guard
src/proxy.ts
API integration
- Typed API client
src/lib/api/client.ts - API proxy
src/app/api/proxy/[...path]/route.ts - External REST API
Other components
- User
Connections 29
- User → Auth routes: opens auth
src/app/(auth)/login/page.tsx - User → Dashboard: opens dashboard
src/app/(dashboard)/dashboard/page.tsx - Auth routes → Login form: renders
src/app/(auth)/login/page.tsx - Auth routes → Registration form: renders
- Login form → Auth schemas: validates with
src/features/auth/components/login-form.tsx - Registration form → Auth schemas: validates with
src/features/auth/components/register-form.tsx - Login form → Auth actions: submits to
src/features/auth/components/login-form.tsx - Registration form → Auth actions: submits to
src/features/auth/components/register-form.tsx - Email verification → Auth actions: calls
src/app/(auth)/verify-email/verify-email-status.tsx - Auth actions → Auth schemas: validates with
src/features/auth/actions/auth-actions.ts - Auth actions → Auth API: calls login/register
src/features/auth/actions/auth-actions.ts - Auth actions → Typed API client: calls
src/features/auth/actions/auth-actions.ts - Auth actions → Session cookies: sets and clears
src/features/auth/actions/auth-actions.ts - Auth actions → JWT verification: reads expiry
src/features/auth/actions/auth-actions.ts - Auth API → Typed API client: requests through
src/features/auth/api/auth-api.ts - Dashboard → Session access: checks session
src/app/(dashboard)/dashboard/page.tsx - Dashboard → Role gate: renders
src/app/(dashboard)/dashboard/page.tsx - Session access → Session cookies: reads token
src/lib/auth/session.ts - Session access → JWT verification: verifies token
src/lib/auth/session.ts - Role gate → JWT verification: uses role type
src/components/shared/role-gate.tsx - Refresh handler → Token refresh: refreshes tokens
src/app/api/auth/refresh/route.ts - Refresh handler → Session cookies: reads and sets
src/app/api/auth/refresh/route.ts - Route guard → Session access: guards routes
- Route guard → Auth routes: routes by policy
src/proxy.ts - Typed API client → Session cookies: reads access token
src/lib/api/client.ts - Typed API client → External REST API: fetches endpoints
src/lib/api/client.ts - API proxy → External REST API: forwards requests
src/app/api/proxy/[...path]/route.ts - User state hook → Auth actions: calls user action
src/features/auth/hooks/use-user.ts - Query provider → User state hook: provides query state