Next.js dashboard behind `<RequireRole>`
A Next.js App Router dashboard gated by role, with SSR auth.
Combines createNextAuthHelpers (server-side auth) with <RequireRole> (client-side gating).
For client components inside the admin tree that need finer-grained gating (e.g. a permission inside a role), use <RequirePermission>:
Why two layers
- Server layout check — protects the URL. Direct navigation never sees the page.
- Client guard — protects sub-components. Fast feedback, no re-render flicker.
The server check is the security boundary. The client guard is for UX.