# authjs-skills

An agent skill that walks through Auth.js v5 authentication in Next.js: Google OAuth, email and password sign-in, environment variables.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 791 installs · ★ 23
- Author: gocallum
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/gocallum/nextjs16-agent-skills/tree/HEAD/skills/authjs-skills/SKILL.md
- Updated: 2026-01-21
- HTML: https://affpapa.org/en/nevibecode/skills/authjs-skills

## What it does

The skill covers installing and wiring Auth.js v5 into a Next.js project. It walks through creating `auth.ts` at the project root, the route handler at `app/api/auth/[...nextauth]/route.ts`, and an optional `middleware.ts`. Separate sections handle the Google provider and the credentials provider.

Google sign-in needs `AUTH_GOOGLE_ID` and `AUTH_GOOGLE_SECRET` from Google Cloud Console, plus an `AUTH_SECRET`. You can generate the secret with `openssl rand -base64 32` or `pnpm dlx auth secret`, and the skill tells you to keep it in `.env.local` rather than in version control.

Install the package as `pnpm add next-auth@beta`. Auth.js v5 is in beta, so skipping the `@beta` tag pulls v4 and a different API. The credentials path also wants `bcryptjs` and `zod`. Migrating an existing v4 app? The config shape and the `auth()` export changed, so check the migration guide instead of copying your old setup.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add gocallum/nextjs16-agent-skills --skill authjs-skills -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/authjs-skills/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/authjs-skills/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add gocallum/nextjs16-agent-skills --skill authjs-skills -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/authjs-skills/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add gocallum/nextjs16-agent-skills --skill authjs-skills -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/authjs-skills/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install gocallum/nextjs16-agent-skills authjs-skills
```

2. **Manually: put the files in place**
- File: `.github/skills/authjs-skills/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add gocallum/nextjs16-agent-skills --skill authjs-skills -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/gocallum/nextjs16-agent-skills --path skills/authjs-skills
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/authjs-skills/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add gocallum/nextjs16-agent-skills --skill authjs-skills -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/gocallum/nextjs16-agent-skills/tree/HEAD/skills/authjs-skills/SKILL.md

## When to use it
- add Google sign-in to a Next.js app
- build an email and password form with bcrypt hashing
- protect `/dashboard` and `/profile` routes with middleware
- keep auth config in one `auth.ts` instead of scattered files
- generate `AUTH_SECRET` and organise environment variables in `.env.local`

## Example prompts
- set up Auth.js v5 in this Next.js project
- add the Google OAuth provider to `auth.ts`
- configure middleware to redirect signed-out users to `/auth/signin`

## Similar
- [nextjs-authentication](https://affpapa.org/en/nevibecode/skills/nextjs-authentication.md) — skill · 3800 installs
- [nextauth-authentication](https://affpapa.org/en/nevibecode/skills/nextauth-authentication.md) — skill · 1100 installs
- [create-auth](https://affpapa.org/en/nevibecode/skills/create-auth.md) — skill · 13400 installs
- [better-auth](https://affpapa.org/en/nevibecode/skills/mrgoonie-better-auth.md) — skill · 390 installs
- [better-auth-authentication](https://affpapa.org/en/nevibecode/skills/better-auth-authentication.md) — skill · 389 installs
- [oauth](https://affpapa.org/en/nevibecode/skills/oauth.md) — skill · 3000 installs

From the same set: [gocallum/nextjs16-agent-skills](https://affpapa.org/en/nevibecode/by/gocallum/nextjs16-agent-skills.md) — 3 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
