Back to list
vuralserhat86

clerk-auth

by vuralserhat86

OS for Agents: 130+ Agentic Skills, Gemini Protocols, and Autonomous Workflows. (Antigravity System)

19🍴 9📅 Jan 23, 2026

SKILL.md


name: clerk_auth router_kit: SecurityKit description: Clerk modern authentication, WebAuthn, passkeys ve social auth entegrasyonu rehberi. metadata: skillport: category: authentication tags: [accessibility, api integration, backend, browser apis, clerk auth, client-side, components, css3, debugging, deployment, frameworks, frontend, fullstack, html5, javascript, libraries, node.js, npm, performance optimization, responsive design, seo, state management, testing, typescript, ui/ux, web development] - webauthn

🔐 Clerk Auth

Clerk modern authentication rehberi.


📋 Kurulum

npm install @clerk/nextjs

middleware.ts

import { clerkMiddleware } from '@clerk/nextjs/server';

export default clerkMiddleware();

export const config = {
  matcher: ['/((?!.*\\..*|_next).*)', '/', '/(api|trpc)(.*)'],
};

🔧 Provider Setup

// app/layout.tsx
import { ClerkProvider } from '@clerk/nextjs';

export default function Layout({ children }) {
  return (
    <ClerkProvider>
      <html>
        <body>{children}</body>
      </html>
    </ClerkProvider>
  );
}

👤 Components

import { 
  SignInButton, 
  SignUpButton, 
  UserButton,
  SignedIn,
  SignedOut 
} from '@clerk/nextjs';

function Header() {
  return (
    <header>
      <SignedOut>
        <SignInButton />
        <SignUpButton />
      </SignedOut>
      <SignedIn>
        <UserButton />
      </SignedIn>
    </header>
  );
}

🔒 Server-side Auth

import { auth, currentUser } from '@clerk/nextjs/server';

export async function GET() {
  const { userId } = await auth();
  
  if (!userId) {
    return new Response('Unauthorized', { status: 401 });
  }
  
  const user = await currentUser();
  return Response.json({ user });
}

Clerk Auth v1.1 - Enhanced

🔄 Workflow

Kaynak: Clerk Documentation

Aşama 1: Integration

  • Install: @clerk/nextjs paketi ve API Key'ler.
  • Middleware: Public/Private rotaları clerkMiddleware ile ayır.
  • Provider: Root layout'u ClerkProvider ile sarmala.

Aşama 2: UX & Components

  • Header: SignedIn / SignedOut şartlı render yapısı kur.
  • Profile: UserButton veya UserProfile bileşenini ekle.
  • Custom Flow: Gerekirse Custom Sign-in sayfası yap.

Aşama 3: Server Logic

  • Protect: API rotalarında auth().userId kontrolü yap.
  • Data: currentUser() ile kullanıcı verisine eriş.
  • Sync: Webhook kullanarak kullanıcıyı kendi veritabanınla eşle (Opsiyonel).

Kontrol Noktaları

AşamaDoğrulama
1Middleware statik dosyaları (image, css) engellemiyor
2Sign-out sonrası login sayfasına yönlendiriyor
3API request'leri tokensiz atılınca 401 dönüyor

Score

Total Score

60/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

+10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon