better-auth
better-auth is a production-ready authentication framework for TypeScript applications, supporting Next.js, Nuxt, Cloudflare Workers, and 15+ other frameworks. It handles email/password login, OAuth providers, two-factor authentication, passkeys, and role-based access control with built-in D1, PostgreSQL, MongoDB, and MySQL adapters. Deploy in minutes with a CLI, migrations, and pre-built plugins for organizations, SSO, and API keys.
better-auth is a TypeScript authentication framework that adds secure login, OAuth, and session management to web applications across 15+ frameworks.
AI-generated summary based on this skill's SKILL.md
Install
secondsky/claude-skills/better-auth · repository language: TypeScript
git clone https://github.com/secondsky/claude-skills
cp -r claude-skills/plugins/better-auth/skills/better-auth ~/.claude/skills/better-authFrequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
What is better-auth and which frameworks does it support?
better-auth is a production-ready authentication framework for TypeScript applications. It supports Next.js, Nuxt, Cloudflare Workers, and 15+ other frameworks. The framework handles email/password login, OAuth providers, two-factor authentication, passkeys, and role-based access control with built-in adapters for D1, PostgreSQL, MongoDB, and MySQL. You can deploy in minutes using its CLI, migrations, and pre-built plugins for organizations, SSO, and API keys.
How do I add auth to a Next.js app with better-auth?
better-auth makes adding authentication to a Next.js app straightforward. The framework provides a CLI for quick setup, pre-configured adapters for your database, and built-in session management. You can choose email/password authentication, OAuth social login providers, or both. better-auth handles the server-side logic and client-side integration, allowing you to deploy authentication in minutes without complex configuration.
Can better-auth work with Cloudflare D1 database setup?
Yes, better-auth includes a built-in D1 adapter for Cloudflare Workers environments. The framework supports D1 database authentication alongside PostgreSQL, MongoDB, and MySQL. You can set up better-auth with D1 using the CLI and migrations, making it ideal for serverless deployments on Cloudflare's infrastructure.
What advanced authentication features does better-auth provide?
better-auth supports advanced features including two-factor authentication (2FA), passkeys with WebAuthn, multi-tenant organizations, role-based access control (RBAC), magic links, email verification, API key authentication, and SSO/SAML/OIDC setup. These features are available through pre-built plugins and can be integrated into your application to meet enterprise security requirements.
How do I implement OAuth and social login with better-auth?
better-auth provides built-in support for OAuth and social login providers. The framework simplifies provider configuration through its plugin system and CLI setup. You can enable multiple social login options alongside traditional email/password authentication, with better-auth handling token management, user creation, and session establishment automatically.
What should I do if I encounter a D1 adapter error in better-auth?
If you encounter a D1 adapter error in better-auth, verify that your D1 database is properly configured and migrations have run. Check that the D1 adapter is correctly imported and initialized in your authentication setup. Review the better-auth migration guide and ensure your Cloudflare Workers environment has the necessary D1 bindings configured. The framework's error messages typically indicate missing configuration or adapter initialization issues.
SKILL.md
rendered from the published skill — quoted content, verbatim
name: better-auth description: Skill for integrating Better Auth - comprehensive TypeScript authentication framework for Cloudflare D1, Next.js, Nuxt, and 15+ frameworks. Use when adding auth, encountering D1 adapter errors, or implementing OAuth/2FA/RBAC features. license: MIT metadata: keywords: "better-auth, authentication, cloudflare d1 auth, drizzle orm auth, kysely auth, self-hosted auth, typescript auth, clerk alternative, auth.js alternative, social login, oauth providers, session management, jwt tokens, 2fa, two-factor, passkeys, webauthn, multi-tenant auth, organizations, teams, rbac, role-based access, google auth, github auth, microsoft auth, apple auth, magic links, email password, better-auth setup, drizzle d1, kysely d1, session serialization error, cors auth, d1 adapter, nextjs auth, nuxt auth, remix auth, sveltekit auth, expo auth, react native auth, postgresql auth, mongodb auth, mysql auth, stripe auth, api keys, sso, saml, scim, admin dashboard, background tasks, oauth 2.1, cli, electron, i18n, instrumentation, otel, opentelemetry, test-utils, dynamic-base-url, secret-rotation, oauth-provider, mcp, passkey pre-auth, d1 native" version: "3.1.0"
(truncated - see the full file via the links below)
Read as markdown · JSON record · Browse the source repository
File tree — 15 files
plugins/better-auth/skills/better-auth/SKILL.md
plugins/better-auth/skills/better-auth/assets/auth-flow-diagram.md
plugins/better-auth/skills/better-auth/references/advanced-features.md
plugins/better-auth/skills/better-auth/references/cloudflare-worker-drizzle.ts
plugins/better-auth/skills/better-auth/references/cloudflare-worker-kysely.ts
plugins/better-auth/skills/better-auth/references/configuration-guide.md
plugins/better-auth/skills/better-auth/references/database-schema.ts
plugins/better-auth/skills/better-auth/references/databases/mongodb.md
plugins/better-auth/skills/better-auth/references/databases/mysql.md
plugins/better-auth/skills/better-auth/references/databases/postgresql.md
plugins/better-auth/skills/better-auth/references/error-catalog.md
plugins/better-auth/skills/better-auth/references/framework-comparison.md
plugins/better-auth/skills/better-auth/references/frameworks/api-frameworks.md
plugins/better-auth/skills/better-auth/references/frameworks/expo-mobile.md
plugins/better-auth/skills/better-auth/references/frameworks/nextjs.md