better-auth-integrations — Claude Code skill: how to install
Configures Better Auth route handlers in TypeScript web frameworks like Next.js, Remix, Hono, and Express. Solves cookie and header forwarding for SSR and server actions.
npx skills add bobmatnyc/claude-mpm-skills --skill better-auth-integrations -a claude-codeWhat better-auth-integrations does
This skill gives your coding agent reference patterns for integrating Better Auth into TypeScript projects. It targets Next.js App Router and Pages Router, Remix, SvelteKit, Express, and Hono. The primary objective is wiring the /api/auth/* catch-all endpoint without header or cookie issues during SSR.
The skill specifies official helper functions for each environment. Next.js App Router mounts routes through toNextJsHandler(auth). Pages Router endpoints wrap auth.handler using toNodeHandler. When Next.js server actions handle authentication, the skill requires adding the nextCookies() plugin from better-auth/next-js.
Running a body parser before Better Auth breaks incoming authentication payloads. Pages Router routes must set bodyParser: false. Client and server paths must match exactly.
What it helps with
- mount a catch-all
/api/auth/*handler in Next.js App Router - configure Next.js Pages Router authentication with
bodyParserdisabled - handle session cookies in Next.js server actions via
nextCookies - align authentication base paths between client and server
Example prompts for the agent
- Mount Better Auth handlers in Next.js App Router under
/api/auth/[...all]/route.ts - Set up Better Auth inside Next.js Pages Router and disable the default body parser
- Configure the
nextCookiesplugin in Better Auth so server actions can write cookies
How to install better-auth-integrations
1Skills CLI (Vercel)
npx skills add bobmatnyc/claude-mpm-skills --skill better-auth-integrations -a claude-code2Manually: put the files in place
~/.claude/skills/better-auth-integrations/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/better-auth-integrations/
1Skills CLI (Vercel)
npx skills add bobmatnyc/claude-mpm-skills --skill better-auth-integrations -a codex2Manually: put the files in place
.agents/skills/better-auth-integrations/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add bobmatnyc/claude-mpm-skills --skill better-auth-integrations -a cursor2Manually: put the files in place
.cursor/skills/better-auth-integrations/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install bobmatnyc/claude-mpm-skills better-auth-integrations2Manually: put the files in place
.github/skills/better-auth-integrations/SKILL.md1Skills CLI (Vercel)
npx skills add bobmatnyc/claude-mpm-skills --skill better-auth-integrations -a gemini-cli2Platform CLI
gemini skills install https://github.com/bobmatnyc/claude-mpm-skills --path toolchains/platforms/auth/better-auth/better-auth-integrationsManually: put the files in place
.devin/skills/better-auth-integrations/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add bobmatnyc/claude-mpm-skills --skill better-auth-integrations -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about better-auth-integrations
How to install better-auth-integrations in Claude Code?
Run npx skills add bobmatnyc/claude-mpm-skills --skill better-auth-integrations -a claude-code in your terminal. The skill file is placed at ~/.claude/skills/better-auth-integrations/SKILL.md.
What does better-auth-integrations do?
It provides coding models with setup rules and code snippets for integrating Better Auth into Next.js, Remix, SvelteKit, Express, and Hono. It ensures /api/auth/* endpoints forward cookies and headers properly during SSR.
Why must bodyParser be disabled in Next.js Pages Router with Better Auth?
Better Auth parses incoming request bodies on its own. If the Next.js built-in body parser processes the payload first, the auth handler fails to read the request.
Source text
SKILL.md · MIT
---
name: better-auth-integrations
description: Better Auth framework integrations for TypeScript. Use when wiring route handlers in Next.js, SvelteKit, Remix, Express, Hono, or other web frameworks.
user-invocable: false
disable-model-invocation: true
progressive_disclosure:
entry_point:
summary: "Better Auth framework integrations for TypeScript. Use when wiring route handlers in Next.js, SvelteKit, Remix, Express, Hono, or other web frameworks."
when_to_use: "When implementing authentication, authorization, or security."
quick_start: "1. Review the core concepts below. 2. Apply patterns to your use case. 3. Follow best practices for implementation."
references:
- frameworks.md
- nextjs.md
---
# Better Auth Integrations
## Goals
- Mount the Better Auth handler at `/api/auth/*` (or a custom base path).
- Use framework helpers where available.
- Ensure cookies and headers flow correctly in SSR and server actions.
## Quick start
1. Create an `auth` instance (see `better-auth-core`).
2. Add a catch-all route for `/api/auth/*`.
3. Use a framework helper (or `auth.handler`) to return a Response.
### Next.js App Router
```ts
import { auth } from "@/lib/auth";
import { toNextJsHandler } from "better-auth/next-js";
export const { GET, POST } = toNextJsHandler(auth);
```
### Next.js Pages Router
```ts
import { auth } from "@/lib/auth";
import { toNodeHandler } from "better-auth/node";
export const config = { api: { bodyParser: false } };
export default toNodeHandler(auth.handler);
```
## Cookie handling in Next.js server actions
Use the `nextCookies` plugin so server actions set cookies correctly.
```ts
import { betterAuth } from "better-auth";
import { nextCookies } from "better-auth/next-js";
export const auth = betterAuth({
// ...config
plugins: [nextCookies()],
});
```
## Guardrails
- Keep the base path consistent between server and client.
- Prefer framework helpers when available.
- Avoid running custom body parsers before the auth handler.
## References
- `toolchains/platforms/auth/better-auth/better-auth-integrations/references/nextjs.md`
- `toolchains/platforms/auth/better-auth/better-auth-integrations/references/frameworks.md`
© bobmatnyc · MIT · bobmatnyc/claude-mpm-skills