本文へスキップ
Skillpedia
セキュリティ33k · #8737

clerk-auth

できること

このスキルにより、AIはアプリにClerkのサインインを追加するパターンを使えます。Clerkでログイン、サインアップ、ルートの保護を行いたい開発者向けです。

使う場面

  • ✓ClerkでNext.jsアプリにサインインやサインアップを追加したいとき。
  • ✓サインインしたユーザーだけがアクセスできるように、特定のページを保護したいとき。
  • ✓サーバーコンポーネントで現在のユーザーを取得したいとき。

スキルのリンク

https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/development/clerk-auth/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/development/clerk-auth/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“私のNext.jsアプリにClerkのサインインを追加し、ダッシュボードのページを保護してください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

エージェントは、Clerkのプロバイダー、ミドルウェア、既製のサインインコンポーネントを設定します。その後、ヘルパー関数を使って、サーバー側でサインイン中のユーザーを読み取り、保護されたルートをブロックします。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Clerk Authentication

Patterns

Next.js App Router Setup

Complete Clerk setup for Next.js 14/15 App Router.

Includes ClerkProvider, environment variables, and basic sign-in/sign-up components.

Key components:

  • ClerkProvider: Wraps app for auth context
  • <SignIn />, <SignUp />: Pre-built auth forms
  • <UserButton />: User menu with session management

Middleware Route Protection

Protect routes using clerkMiddleware and createRouteMatcher.

Best practices:

  • Single middleware.ts file at project root
  • Use createRouteMatcher for route groups
  • auth.protect() for explicit protection
  • Centralize all auth logic in middleware

Server Component Authentication

Access auth state in Server Components using auth() and currentUser().

Key functions:

  • auth(): Returns userId, sessionId, orgId, claims
  • currentUser(): Returns full User object
  • Both require clerkMiddleware to be configured

⚠️ Sharp Edges

Issue Severity Solution
Issue critical See docs
Issue high See docs
Issue high See docs
Issue high See docs
Issue medium See docs
Issue medium See docs
Issue medium See docs
Issue medium See docs
よくある質問

どのNext.jsのバージョンに対応していますか?

App Routerを使ったNext.js 14と15に対応しています。

どの既製コンポーネントがありますか?

SignIn、SignUp、UserButtonのコンポーネントを含みます。

Webhookにも対応していますか?

はい。組織の管理と同様に、Webhookとユーザーの同期も扱います。

詳細

作者による元の説明

Expert patterns for Clerk auth implementation, middleware, organizations, webhooks, and user sync Use when: adding authentication, clerk auth, user authentication, sign in, sign up.

repo: davila7/claude-code-templates

人気

GitHubのスター
33k
ランキング
#8737
ライセンス
MIT
更新日
2026/11/2

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル