clerk-sdk-patterns
Common Clerk SDK patterns and best practices. Use when implementing authentication flows, accessing user data, or integrating Clerk SDK methods in your application. Trigger with phrases like "clerk SDK", "clerk patterns", "clerk best practices", "clerk API usage".
npx skills add majiayu000/claude-skill-registry --skill clerk-sdk-patterns-vasic-digital-superagent-2 --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# Clerk SDK Patterns ## Overview Learn common patterns and best practices for using the Clerk SDK effectively. ## Prerequisites - Clerk SDK installed and configured - Basic understanding of React/Next.js - ClerkProvider wrapping application ## Instructions ### Pattern 1: Server-Side Authentication ```typescript // app/api/protected/route.ts import { auth, currentUser } from '@clerk/nextjs/server' export async function GET() { // Quick auth check const { userId, sessionId, orgId } = await auth() if (!userId) { return Response.json({ error: 'Unauthorized' }, { status: 401 }) } // Full user data when needed const user = await currentUser() return Response.json({ userId, sessionId, orgId, email: user?.primaryEmailAddress?.emailAddress }) } ``` ### Pattern 2: Client-Side Hooks ```typescript 'use client' import { useUser, useAuth, useClerk, useSession } from '@clerk/nextjs' export function AuthenticatedComponent() { // User data and loading state const { user, isLoaded, isSignedIn } = useUser() // Auth utilities const { userId, getToken, signOut } = useAuth() // Full Clerk instance const clerk = useClerk() // Session info const { session } = useSession() // Get JWT token for API calls co
- Overview
- Prerequisites
- Instructions
- Pattern 1: Server-Side Authentication
- Pattern 2: Client-Side Hooks
- Pattern 3: Protected Routes with Middleware
- Pattern 4: Organization-Aware Queries
- Pattern 5: Custom JWT Templates
- Output
- Error Handling
- Examples
- Complete Protected Page Pattern
- Typed User Metadata
- Resources
What does the clerk-sdk-patterns skill do?
Common Clerk SDK patterns and best practices. Use when implementing authentication flows, accessing user data, or integrating Clerk SDK methods in your application. Trigger with phrases like "clerk SDK", "clerk patterns", "clerk best practices", "clerk API usage".
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill clerk-sdk-patterns-vasic-digital-superagent-2 --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
