Agent skill
better-auth-integrations
Better Auth framework integrations for TypeScript. Use when wiring route handlers in Next.js, SvelteKit, Remix, Express, Hono, or other web frameworks.
Install this agent skill to your Project
npx add-skill https://github.com/bobmatnyc/claude-mpm-skills/tree/main/toolchains/platforms/auth/better-auth/better-auth-integrations
SKILL.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
- Create an
authinstance (seebetter-auth-core). - Add a catch-all route for
/api/auth/*. - Use a framework helper (or
auth.handler) to return a Response.
Next.js App Router
import { auth } from "@/lib/auth";
import { toNextJsHandler } from "better-auth/next-js";
export const { GET, POST } = toNextJsHandler(auth);
Next.js Pages Router
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.
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.mdtoolchains/platforms/auth/better-auth/better-auth-integrations/references/frameworks.md
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
bad-example-skill
ANTI-PATTERN - Example showing violations of self-containment (DO NOT COPY)
example-framework-skill
Example of a properly self-contained skill following all best practices
systematic-debugging
Systematic debugging methodology emphasizing root cause analysis over quick fixes
verification-before-completion
Run verification commands and confirm output before claiming success
Root Cause Tracing
Systematically trace bugs backward through call stack to find original trigger
Brainstorming Ideas Into Designs
Interactive idea refinement using Socratic method to develop fully-formed designs
Didn't find tool you were looking for?