vercel/vercel-plugin/auth
Claude Code and agent skill by vercel/vercel-plugin
- vendor
Checking that the SKILL.md file is still in the repository.
Authentication integration guidance — Clerk (native Vercel Marketplace), Better Auth, Descope, and Auth0 setup for Next.js applications, plus Sign in with Vercel, Vercel Passport, and Vercel KMS. Covers server config, route handlers, proxy.ts auth patterns, sign-in/sign-up flows, and Marketplace provisioning. Use when implementing user authentication, sessions, protected routes, or protecting deployments.
Install
npx vskill@latest install vercel/vercel-plugin/authSKILL.md
The same SKILL.md was published earlier as vercel/vercel-plugin/auth.
Authentication Integrations
You are an expert in authentication for Vercel-deployed applications — covering Clerk (native Vercel Marketplace integration), Better Auth (self-hosted, with data in your own database), Descope, and Auth0 for application sign-in, plus Vercel's own primitives: Sign in with Vercel (OAuth/OIDC provider), Passport (deployment protection with your identity provider), and KMS (managed signing keys).
All Next.js examples target Next.js 16, where the request-interception file is proxy.ts (exporting proxy). On Next.js 15 or earlier the same code lives in middleware.ts (exporting middleware).
Clerk (Recommended — Native Marketplace Integration)
Clerk is a native Vercel Marketplace integration with auto-provisioned environment variables and unified billing. Current SDK: @clerk/nextjs v7 (Core 3, March 2026).
Install via Marketplace
Auto-provisioned environment variables:
CLERK_SECRET_KEY— server-side API keyNEXT_PUBLIC_CLERK_PUBLISHABLE_KEY— client-side publishable key
SDK Setup
Proxy Configuration
Protect Routes
Frontend API Proxy (Core 3)
Proxy Clerk's Frontend API through your own domain to avoid third-party requests:
Provider Setup
Sign-In and Sign-Up Pages
Add routing env vars to .env.local:
Access User Data
API Route Protection
Better Auth (Self-Hosted)
Better Auth is a framework-agnostic TypeScript auth library that runs inside your app. Users, sessions, and accounts live in your own database, so the only external dependency is the database itself. Choose it when the user wants auth inside their app with data in their own database, or is building on a framework other than Next.js. Current release line: v1.7.
Agent Workflow
- Detect framework (Next.js App/Pages Router, SvelteKit, Nuxt, Hono…), database/ORM (
prisma/schema.prisma,drizzle.config.ts,pg,@neondatabase/serverless), and package manager from the lockfile. - Install
better-authplus the DB driver. Provision Postgres from the Marketplace if the project has no database. - Create
lib/auth.ts(server) andlib/auth-client.ts(client). - Mount the route handler at
app/api/auth/[...all]/route.ts. - Migrate with
npx auth@latest migrate(built-in adapter) orgenerate+ the ORM's migrate (Prisma/Drizzle). - Protect routes: cookie check in
proxy.ts, realgetSession()in pages/route handlers. - Verify
GET /api/auth/okreturns{ "status": "ok" }, then run a sign-up → sign-in →getSession()pass. - Re-run migrate after every plugin change.
Install
Environment Variables
- Production: set
BETTER_AUTH_URLto your production domain. - Preview: leave
BETTER_AUTH_URLunset for the Preview environment. Better Auth infers the base URL from the incoming request, so every preview URL works without config.VERCEL_URLis not read automatically. - OAuth providers need registered redirect URIs (
<base>/api/auth/callback/<provider>), so social login on previews needs a stable branch alias.
Server Config
Prisma / Drizzle / MongoDB users pass an adapter instead of a pool: prismaAdapter(prisma, { provider: "postgresql" }) from better-auth/adapters/prisma, drizzleAdapter(db, { provider: "pg" }) from better-auth/adapters/drizzle.
Route Handler
Database Schema
Re-run after adding or removing plugins. Verify with GET /api/auth/ok → { "status": "ok" }.
Client
Access Session Data (Server)
Every endpoint (including plugin endpoints) is callable server-side via auth.api.* — no HTTP round-trip.
Protect Routes
Only check for the session cookie in middleware/proxy — never call the database there. Do the real check in the page or route handler.
Keep It Fast on Vercel
- Cookie cache on (
session.cookieCache) — avoids a DB read per request in Fluid Compute functions. - Redis for shared state —
vercel integration add upstash, then pass asecondaryStorageadapter. Sessions and rate-limit counters move to Redis; the default in-memory rate limiter does not share state across function instances. SetrateLimit.storage: "secondary-storage". - Import plugins from subpaths for tree-shaking:
import { twoFactor } from "better-auth/plugins/two-factor", not"better-auth/plugins". - Cookie check only in middleware —
getSessionCookie()is synchronous and works on the Edge runtime;auth.api.getSession()in middleware requires the Node.js runtime and costs a DB hit per request. - Separate frontend origin? Add it to
trustedOrigins(wildcards allowed:"https://*.vercel.app"). Same-origin apps need nothing.
Common Mistakes
| Symptom | Cause | Fix | |
|---|---|---|---|
| Cookies not set from a Server Action | nextCookies() missing or not last in plugins | Add it as the last plugin | |
| Middleware slow or fails on Edge | auth.api.getSession() in middleware | Use getSessionCookie(); verify in the page | |
| "Invalid origin" on a separate frontend | Origin not trusted | Add it to trustedOrigins | |
| Type errors or missing tables after adding a plugin | Schema not regenerated | Re-run npx auth@latest migrate / generate | |
| Adapter can't find a model | Config uses the DB table name | Use the ORM model name (modelName: "user", not "users") | |
| Rate limits reset per request in production | Default in-memory rate-limit storage | Use secondaryStorage (Redis) or rateLimit.storage: "database" | |
| Callback URL wrong on Vercel | BETTER_AUTH_URL points at localhost or a preview | Set the production domain in Production; leave unset for Preview |
Plugins
Server plugin + matching client plugin + re-run migrations.
| Feature | Server import | Client plugin | |
|---|---|---|---|
| Two-factor (TOTP/OTP) | twoFactor from better-auth/plugins/two-factor | twoFactorClient | |
| Organizations / teams | organization from better-auth/plugins/organization | organizationClient | |
| Magic link | magicLink from better-auth/plugins/magic-link | magicLinkClient | |
| Admin / user management | admin from better-auth/plugins/admin | adminClient | |
| Passkeys (WebAuthn) | passkey from @better-auth/passkey | passkeyClient | |
| Enterprise SSO (SAML/OIDC) | sso from @better-auth/sso | — | |
| Stripe subscriptions | stripe from @better-auth/stripe | stripeClient | |
| Sign in through a Vercel Connect connector | genericOAuth from better-auth/plugins/generic-oauth + connect from @vercel/connect/betterauth | — (v1.7 signs in with authClient.signIn.social; genericOAuthClient only exists on v1.6 and earlier) |
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files. Certified 30 Sep 2026.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/auth/SKILL.md
Popularity
- Repository stars
- 287
- Repository forks
- 58
- 7-day trend score
- 28
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 16 Mar 2026, 8 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/vercel/vercel-plugin/auth)