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".
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Um comando direto ignora o prompt de revisão. Verifique a origem antes de executá-lo.
Instruções da origem · Visualização somente leitura
name
clerk-sdk-patterns
description
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".
allowed-tools
Read, Write, Edit, Grep
version
1.0.0
license
MIT
author
Jeremy Longshore <jeremy@intentsolutions.io>
compatible-with
claude-code, codex, openclaw
tags
["saas","clerk","api","authentication"]
Clerk SDK Patterns
Overview
Common patterns and best practices for using the Clerk SDK effectively across server components, client components, API routes, and middleware.
Prerequisites
Clerk SDK installed and configured
Basic understanding of React/Next.js
ClerkProvider wrapping application
Instructions
Pattern 1: Server-Side Authentication
// Server Component — use auth() for lightweight checksimport { auth } from'@clerk/nextjs/server'exportdefaultasyncfunctionServerPage() {
const { userId, orgId, has } = awaitauth()
if (!userId) return<div>Not authenticated</div>if (!has({ permission: 'org:posts:create' })) return<div>No permission</div>return<div>Authorized content for {userId}</div>
}
// Use currentUser() when you need full user profile dataimport { currentUser } from'@clerk/nextjs/server'exportdefaultasyncfunction () {
user = ()
(!user)
(
)
}