clerk-react-router-patterns
CommunitySecure React Router apps with Clerk auth
AuthorRoyMcCrain
Version1.0.0
Installs0
System Documentation
What problem does it solve?
Provides clear, repeatable patterns for integrating Clerk authentication with React Router v7 so teams can implement secure server- and client-side auth without subtle bugs like missing middleware or infinite redirect loops.
Core Features & Use Cases
- Middleware + Loader Integration: Shows how to install clerkMiddleware and call rootAuthLoader so getAuth works reliably in nested loaders and actions.
- Loader and Action Protection: Demonstrates using getAuth inside loaders and actions to perform server-side redirects, 401/403 responses, and scoped data fetching.
- SSR and Client Hooks: Explains fetching SSR user data via clerkClient/getAuth and consuming reactive client hooks such as useAuth and useUser.
- Organization Support: Covers org-scoped loaders and the OrganizationSwitcher component for B2B flows.
- Use Case: Protect a /dashboard route, redirect unauthenticated users to /sign-in, and load org-specific data when orgId is present.
Quick Start
Add clerkMiddleware to your root route, call rootAuthLoader in your root.tsx loader, and use getAuth in any protected loader or action to validate userId and orgId before fetching data.
Dependency Matrix
Required Modules
None requiredComponents
references
💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: clerk-react-router-patterns Download link: https://github.com/RoyMcCrain/dotsfile/archive/main.zip#clerk-react-router-patterns Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.