About better-auth
A guidance skill for developers building self-hosted TypeScript authentication with Better Auth. It covers setup, plugins, database adapters, framework integration, security, and version upgrades.
Key features
- 01Server and client setup guidance
- 02Plugin and database adapter guidance
- 03Framework mounts and session checks
- 04Upgrade and security checks
Use cases
- 01Configure Better Auth sign-in and sessions
- 02Add plugins and generate database schemas
- 03Upgrade auth dependencies and review risks
Install
Copy the command and run it in a terminal.
npx skills add https:/ / github.com/ dobroslavradosavljevic/ skills --skill better-authAfter installing, type/better-authin Claude Code to confirm it loaded.
Bundled files
References and scripts installed along with SKILL.md.
agents/openai.yamlreferences/adapters-schema.mdframeworks-client.mdplugins-ecosystem.mdsecurity-patterns.mdsource-map.mdusage-guide.mdDetails
From the project READMEBetter Auth
Use this skill for self-hosted TypeScript authentication with Better Auth ([email protected]): server instance, client SDK, plugins, adapters, framework mounts, and security.
Snapshot: 2026-10-01. latest is 1.7.7 (stable). Do not treat 1.7 as rc/beta. Require ≥ 1.7.7: earlier versions (back to 1.4.0-beta.18) have a critical Magic Link account takeover (GHSA-965c-763c-88jm) and an OAuth Proxy takeover (GHSA-r4xp-prcw-77qf); no 1.6.x fix exists. Refresh from source-map.md if versions differ.
Workflow
- Inspect the local surface:
- Core:
better-auth(snapshot 1.7.7). CLI:bunx auth@latest(package[email protected]) — not stale@better-auth/[email protected]. CLI needs Node.js ≥ 22.12. - Env:
BETTER_AUTH_SECRET(≥32),BETTER_AUTH_URL/baseURL,trustedOrigins. - Database: Kysely/pool vs Drizzle/Prisma/Mongo adapter; secondary storage (Redis). Schema validation is on by default.
- Plugins: server + matching client plugins; schema generated after changes.
- Mount:
/api/auth/*(defaultbasePath) viaauth.handler/ framework helper.
- Core:
- For day-to-day setup, follow usage-guide.md first. From 1.6, start with
bunx auth@latest upgradeand the 1.7 upgrade guide — generated SQL is not the full upgrade. - Refresh docs when versions drift. Start from source-map.md.
- Route deeper detail:
- Plugins & scoped packages: plugins-ecosystem.md.
- Schema, adapters, CLI: adapters-schema.md.
- Framework mounts & clients: frameworks-client.md.
- Security, sessions, 1.7 identity/OAuth gotchas: security-patterns.md.
- Align every installed
@better-auth/*at 1.7.x with core (except separate lines:utils,infra,agent-auth,dash). Prefer scoped adapters when optimizing (better-auth/minimal). - Verify with session smoke (
auth.api.getSession), sign-in/out, plugin schema migrate, and production secret/origins checks.
Core Judgment
- Cookie DB sessions by default — not JWT. Use
jwt/bearer/ API keys only when cookies aren’t enough. - Singleton
authinlib/auth.ts(named export helps CLI discovery). Separateauth-client.ts. - Server:
auth.api.*with real request headers. Client:createAuthClient+ framework entry (better-auth/react, …). - Most features are plugins: register server + client, then
bunx auth@latest generate(ORM) ormigrate(Kysely). - Passkey / API key / SSO / SCIM / OAuth-provider / MCP / CIMD / Stripe / Expo are scoped packages. MCP is
@better-auth/mcp, notbetter-auth/plugins. oidcProvideris removed. Use@better-auth/oauth-provider. Do not also registeroauthProvider()next tomcp()—mcp()is the provider.- Generic OAuth uses
signIn.social/linkSocialand/api/auth/callback/:id. There is nogenericOAuthClient(). - Never treat middleware cookie presence as auth — validate session. Don’t disable CSRF/origin checks to “fix” CORS.
- Upgrading to 1.7.7 is a coordinated cutover: upgrade every server sharing verification storage and every OAuth Proxy participant together; pending Magic Links and OAuth/SAML state from before the upgrade stop working.
- Rate limit is off/weak in dev; memory storage fails on multi-instance — use Redis/DB in prod.
- Prefer
bun/bunxin command examples.
Verification
Prefer repository-owned commands. Cover the relevant subset:
bun pm ls better-authand matching@better-auth/*versions (all 1.7.x together, ≥ 1.7.7).bunx auth@latest info/secretas needed; schemagenerate/migrateafter plugin changes; read-onlybunx auth@latest check schemato validate the adapter schema.- Smoke: mount handler,
getSession, email or social sign-in, sign-out. - Plugins: client methods resolve; org/2FA/passkey/OAuth-provider/MCP flows if enabled.
- Prod:
baseURL, secret length,trustedOrigins, HTTPS cookies, rate-limit storage, schema validation not failing. - Security: roles/
additionalFieldswithinput: false; notestUtilsin prod config. - After 1.6→1.7: Microsoft
oidrows, OAuth clients, SCIM reprovision, Expoawait getCookie(), and 1.7.0–1.7.2issuercleanup if that schema was applied.
Report which checks ran, which did not, and version assumptions that remain.