What problem does it solve?
This skill solves the complexity of adding OIDC-based authentication to a React frontend and protecting Fastify API routes using a consistent, portable @mbe/auth layer.
Core Features & Use Cases
- React AuthProvider + hooks: Initialize authentication state with
AuthProvider and manage sign-in, sign-out, and session-aware UI using useAuth, useAccessToken, and useRequireAuth.
- Fastify JWT protection: Register
authPlugin to validate bearer JWTs and populate request.user, or apply requireAuth per-route for fine-grained access control.
- Environment-driven configuration for Auth0: Configure authority, clientId, redirectUri, and audience via Vite and Node environment variables, aligned to an Auth0 OIDC setup.
- Testing patterns (unit + E2E): Mock
useAuth in Vitest for deterministic component testing and use Playwright with programmatic Auth0 login fixtures for authenticated E2E flows.
Quick Start
Use this skill to add authentication by wrapping your React app with AuthProvider, then protect Fastify routes by registering authPlugin and adding requireAuth where needed.