Sponsored byOutsenseAI that finds your next clients
SponsorGROUOutbound, LinkedIn content and leads for B2B teamsSponsorOutsenseAI that finds your next clientsAd+Your tool hereSeen by people installing AI tools@Weekly picksThe best new tools, one email a week

clerk-nextjs-patterns

Skill by baohuy2209

Adds Clerk authentication patterns to Next.js projects, including middleware, Server Actions, API routes and user-scoped caching. Aimed at developers who already use the Clerk SDK in a Next.js app.

  • Score 54
  • 0 stars
  • MIT
  • Updated
Works withClaude CodeClaude apps Antigravity CLI

Install clerk-nextjs-patterns

Built from the published package, never by AI.

git clone --depth 1 https://github.com/baohuy2209/microservice-bh-shop /tmp/microservice-bh-shop && mkdir -p ~/.claude/skills && cp -r /tmp/microservice-bh-shop/.codebuddy/skills/clerk-nextjs-patterns ~/.claude/skills/clerk-nextjs-patterns

Run in your terminal. Claude Code loads skills from ~/.claude/skills automatically.

Step-by-step: install clerk-nextjs-patterns in Claude Code

Skills can run scripts on your machine. Some need an API key: check the README.

About

This skill is a set of reference notes for adding Clerk authentication to Next.js apps. It explains when to use the server auth() function from @clerk/nextjs/server and when to use the useAuth() hook in client components. It also covers middleware setup with public-first or protected-first strategies, protecting Server Actions, and returning 401 or 403 errors from API routes. Other sections show how to cache auth data per user, pass Clerk JWT templates to external APIs with getToken(), and verify session tokens manually in standalone API servers.

The skill is written for developers building Next.js applications with Clerk. It includes callouts for Core 2 versions of the SDK, and notes that Next.js 15 and earlier use middleware.ts instead of proxy.ts. It points to the clerk-setup skill for basic setup and the clerk-orgs skill for organizations.

Written from the project's SKILL.md and checked against it.

What it can do

  • Server vs client authExplains await auth() on the server and the useAuth() hook in client components.
  • Middleware strategiesCovers public-first and protected-first middleware configuration.
  • Server Actions protectionShows how to check auth at the start of a Server Action.
  • API route authExplains when to return 401 for not signed in and 403 for no permission.
  • User-scoped cachingShows how to include userId in cache keys so data is not shared between users.
  • getToken for external APIsPasses a Clerk JWT template token to third-party services such as Hasura or Supabase.
  • Session data in clientsReads session metadata in client components with useSession().
  • Manual JWT verificationVerifies Clerk session tokens in standalone API servers with @clerk/backend or jsonwebtoken.

What you need

  • Next.js project
  • Clerk SDK (@clerk/nextjs)
  • JWT templates defined in the Clerk dashboard for getToken()
  • CLERK_JWT_KEY or CLERK_PEM_PUBLIC_KEY for manual token verification

Try asking

  • Protect my Next.js Server Action so only signed-in users can run it
  • Set up user-scoped caching for my Clerk auth data in Next.js
  • Show me how to call a Supabase API with a Clerk JWT template

Good to know

  • Core 2 SDK users cannot use isAuthenticated or sessionStatus and must check !!userId instead.
  • Core 2 users must use SignedIn and SignedOut components instead of Show.
  • Next.js 15 and earlier use middleware.ts instead of proxy.ts.

Security check

A

No download-and-run commands, hidden instructions or signs of sending keys out were found.

Checked automatically: .codebuddy/skills/clerk-nextjs-patterns/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work

Inside the skill

Allowed tools: WebFetch

Alternatives to clerk-nextjs-patterns

All alternatives →
openclaw-github-repo-commandersickn33
94

Runs a 7-stage workflow for auditing, cleaning up and reviewing GitHub repositories, plus competitor analysis. Written for developers who want a repo checked for secrets, junk files and documentation gaps.

AAA Skill 50k
gradiogradio-app
94

Teaches an AI assistant to build, debug and explain Gradio web UIs and ML demos in Python. It covers the core API, components, event listeners, layouts and the MCP server option. Aimed at Python developers who work with Gradio.

AAA Skill 44k
hig-components-menussickn33
94

Recommends menus, buttons, toolbars and disclosure controls for Apple platforms using Human Interface Guidelines conventions. Built for developers and designers making iOS, iPadOS, macOS or visionOS interfaces. Checks existing project design context before asking questions.

AAA Skill 50k
fastapi-templateswshobson
94

Creates production-ready FastAPI project structures with async patterns, dependency injection, and error handling. It is for developers starting new FastAPI applications or backend API projects.

AAA Skill 43k
appfunctionsandroid
94

Analyzes Android apps to find user workflows to expose as AppFunctions, so AI agents and system shortcuts can run them without opening the app UI. Generates Kotlin code and refines KDoc for Android developers.

AAA Skill 11k
agent-qa-authoringsickn33
94

Creates, edits, validates and runs Agent QA tests, suites and hooks through MCP or CLI. It keeps canonical IDs and schema contracts intact, for developers and QA teams using Agent QA.

AAA Skill 50k

Compare with openclaw-github-repo-commander, gradio or hig-components-menus

clerk-nextjs-patterns: common questions

Does this skill explain when to return 401 or 403 errors?

Yes. The source says 401 means the user is not signed in and 403 means the user has no permission. It also covers this in the API routes reference.

Which Clerk SDK versions does it cover?

The source includes inline callouts for Core 2 differences and says to check package.json for the SDK version. It refers to a version table in the clerk skill.

Can I verify Clerk tokens without Clerk middleware?

Yes. The source shows manual verification for standalone API servers using @clerk/backend verifyToken, or jsonwebtoken with the RS256 algorithm.

How do I install clerk-nextjs-patterns?

Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.

Is clerk-nextjs-patterns free?

The code is published under the MIT licence. The service it connects to may have its own pricing.

Is clerk-nextjs-patterns safe to use?

It scores 54 of 100. Grades: maintenance B, licence A, quality C. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.

What are alternatives to clerk-nextjs-patterns?

Similar skills: openclaw-github-repo-commander, gradio, hig-components-menus, fastapi-templates.

clerk-nextjs-patterns Install

Add to stack

Loading.