kushalkambar5/barbiller/clerk-react-router-patterns
Claude Code and agent skill by kushalkambar5/barbiller
Trust tier 3
- community
Source check pending
Checking that the SKILL.md file is still in the repository.
'React Router v7 patterns with Clerk — rootAuthLoader, getAuth in loaders,
Install
npx vskill@latest install kushalkambar5/barbiller/clerk-react-router-patternsSKILL.md
The same SKILL.md was published earlier as midudev/autoskills/clerk-react-router-patterns.
React Router Patterns
SDK: @clerk/react-router v3+. Requires React Router v7.9+.
What Do You Need?
| Task | Reference | |
|---|---|---|
| Auth in loaders and actions | references/loaders-actions.md | |
| Protected routes and redirects | references/protected-routes.md | |
| SSR user data and session | references/ssr-auth.md |
Mental Model
React Router v7 uses a middleware + loader pipeline. Clerk plugs into both layers:
- Middleware (
clerkMiddleware()) — runs on every request, attaches auth to context - `rootAuthLoader` — required in
root.tsxto pass Clerk state to the client - `getAuth(args)` — called inside any loader/action to get the current user
Minimal Setup
1. root.tsx
2. Middleware (root route or entry.server.ts)
Required:rootAuthLoadermust be called inroot.tsx's loader. Without it,getAuththrows in nested loaders.
Auth in Loaders
Auth in Actions
Client Components
Org Switching
Common Pitfalls
| Symptom | Cause | Fix | |
|---|---|---|---|
clerkMiddleware() not detected | Missing middleware | Export middleware = [clerkMiddleware()] from root route | |
getAuth returns empty userId | rootAuthLoader not called | Call rootAuthLoader(args) in root.tsx loader | |
| Infinite redirect loop | Redirect target is also protected | Exclude /sign-in from protection check | |
redirect not working in action | Using Response instead of throw redirect() | Use throw redirect('/path') from react-router |
Import Map
| What | Import From | |
|---|---|---|
getAuth | @clerk/react-router/server | |
rootAuthLoader | @clerk/react-router/server | |
clerkMiddleware | @clerk/react-router/server | |
ClerkApp | @clerk/react-router | |
useAuth, useUser | @clerk/react-router | |
OrganizationSwitcher | @clerk/react-router |
See Also
clerk-setup- Initial Clerk installclerk-custom-ui- Custom flows & appearanceclerk-orgs- B2B organizations
Docs
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingapp/.agents/skills/clerk-react-router-patterns/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/kushalkambar5/barbiller/clerk-react-router-patterns)