What problem does it solve?
This skill solves the problem of implementing reliable authentication flows in a React SPA using Clerk without brittle state handling or unsafe route protection.
Core Features & Use Cases
- ClerkProvider bootstrapping for Vite/CRA: Configure a React SPA to initialize Clerk at the app root with the correct
VITE_CLERK_PUBLISHABLE_KEY environment variable.
- Hook-safe auth state management: Use
useAuth, useUser, and useClerk correctly, including the required isLoaded guard before trusting isSignedIn.
- Protected routing with React Router: Protect
/dashboard and other routes by redirecting unauthenticated users to /sign-in, including React Router v6/v7 patterns.
- Custom sign-in/sign-up flows: Implement email/password sign-in and sign-up using Clerk hooks (
useSignIn, useSignUp) and activate sessions when complete.
- API token usage: Fetch a session JWT via
getToken() and attach it as Authorization: Bearer <token> for backend calls.
Quick Start
Use the clerk-react-patterns skill to add ClerkProvider to your React app root, then implement a ProtectedRoute for React Router v6/v7 and a custom sign-in form using useSignIn.