Research-mind toolchains-platforms-auth-better-auth-better-auth-integrations
Better Auth Integrations
install
source · Clone the upstream repo
git clone https://github.com/MacPhobos/research-mind
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/MacPhobos/research-mind "$T" && mkdir -p ~/.claude/skills && cp -r "$T/.claude/skills/toolchains-platforms-auth-better-auth-better-auth-integrations" ~/.claude/skills/macphobos-research-mind-toolchains-platforms-auth-better-auth-better-auth-integr && rm -rf "$T"
manifest:
.claude/skills/toolchains-platforms-auth-better-auth-better-auth-integrations/skill.mdsource content
Better Auth Integrations
Goals
- Mount the Better Auth handler at
(or a custom base path)./api/auth/* - Use framework helpers where available.
- Ensure cookies and headers flow correctly in SSR and server actions.
Quick start
- Create an
instance (seeauth
).better-auth-core - Add a catch-all route for
./api/auth/* - Use a framework helper (or
) to return a Response.auth.handler
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