clerk-nextjs-patterns

Advanced Next.js patterns for authentication, middleware, Server Actions, and user-scoped caching with Clerk.

clerk ↓ 28k
Claude Code
View source ↗

What it does

  • Server: await auth() from @clerk/nextjs/server (async!)
  • Client: useAuth() hook from @clerk/nextjs (sync)
  • isAuthenticated — boolean, replaces the !!userId pattern
  • sessionStatus — 'active' | 'pending', for detecting incomplete session tasks
  • userId, orgId, orgSlug, has(), protect() — unchanged
  • Same-origin requests: session cookie (Clerk sets this automatically)
  • Cross-origin / mobile / API-to-API: Authorization: Bearer <token> header

Requirements & configuration

  • What Do You Need?
  • const token = await getToken({ template: 'hasura' })
  • if (!token) return <p>Not authenticated</p>
  • headers: { Authorization: Bearer ${token} },
  • const token = await getToken({ template: 'supabase' })

Derived from the skill's own SKILL.md documentation · extracted 2026-07-23

Advanced Next.js patterns for authentication, middleware, Server Actions, and user-scoped caching with Clerk.

Source

Repository: https://github.com/clerk/skills

clerk-nextjs-patterns FAQ

What does the clerk-nextjs-patterns skill do?

Advanced Next.js patterns - middleware, Server Actions, caching with Clerk. Server: await auth() from @clerk/nextjs/server (async!) Client: useAuth() hook from @clerk/nextjs (sync)

What does clerk-nextjs-patterns require?

What Do You Need? const token = await getToken({ template: 'hasura' }) if (!token) return <p>Not authenticated</p> headers: { Authorization: Bearer ${token} }, const token = await getToken({ template: 'supabase' })

How do I install clerk-nextjs-patterns?

Run: npx -y skills add https://github.com/clerk/skills --skill clerk-nextjs-patterns --agent claude-code — the source lives at github.com/clerk/skills.

Maintain clerk-nextjs-patterns?

Let people know it's listed here — add the badge (live metrics, light/dark aware) or a plain link to your README or docs.

clerk-nextjs-patterns on getagentictools
[![clerk-nextjs-patterns on getagentictools](https://getagentictools.com/badge/skills/clerk-skills-clerk-nextjs-patterns.svg)](https://getagentictools.com/skills/clerk-skills-clerk-nextjs-patterns?ref=badge)
npx agentictools info skills/clerk-skills-clerk-nextjs-patterns

The second line is the CLI lookup for this page — handy in READMEs and docs.