better_auth

Implement authentication and authorization in TypeScript applications using the Better Auth framework.

Updated Jan 14, 2026
One-click install
npx skills add https://github.com/jvsandhu/agentic-skills --skill better-auth-jvsandhu
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: better_auth
Source: https://github.com/jvsandhu/agentic-skills/tree/main/skills/better_auth
Command: npx skills add https://github.com/jvsandhu/agentic-skills --skill better-auth-jvsandhu

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires better-auth, and includes scripts (resource) and references (resource) components.

What problem does it solve? Building secure authentication from scratch is error-prone and time-consuming. This Skill guides you through implementing login, signup, OAuth, 2FA, passkeys, and session management in TypeScript applications using the Better Auth framework, so you avoid common security pitfalls. ## Core Features & Use Cases - Multiple Auth Methods: Set up email/password, social OAuth (GitHub, Google), magic links, passkeys/WebAuthn, and username authentication. - Advanced Security: Add two-factor authentication (2FA/TOTP), rate limiting, and role-based access control via plugins. - Framework-Agnostic: Works with Next.js, Nuxt, SvelteKit, Remix, Astro, Hono, Express, and more. - Use Case: You are building a Next.js SaaS app that needs GitHub OAuth login plus email/password signup with email verification. This Skill walks you through server setup, database schema generation, client integration, and protected route middleware. ## Quick Start Ask the AI to set up Better Auth in your TypeScript project with email/password and GitHub OAuth login, including database schema and session management.

Frequently Asked Questions about better_auth

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up authentication in a Next.js app with Better Auth?

Install better-auth, create an auth.ts server instance with your database config, then mount the handler in app/api/auth/[...all]/route.ts using toNextJsHandler. Create a client with createAuthClient and run npx @better-auth/cli generate to build the database schema.

How to add GitHub OAuth login to a TypeScript app?

Add GitHub to the socialProviders config in your Better Auth server instance with your clientId and clientSecret. On the client, call authClient.signIn.social with provider set to github to start the OAuth flow.

Does Better Auth support two-factor authentication and passkeys?

Yes, Better Auth supports 2FA/TOTP through the twoFactor plugin and passwordless login through the passkey plugin for WebAuthn. Both require adding the plugin to your server config and regenerating the database schema.

Which frameworks does Better Auth work with?

Better Auth is framework-agnostic and works with Next.js, Nuxt, SvelteKit, Remix, Astro, Hono, and Express. Each framework mounts the auth handler differently, but the core server and client setup remains the same.

Why is my Better Auth session not persisting after login?

Session issues usually come from a missing or mismatched BETTER_AUTH_URL environment variable, incorrect baseURL in the client config, or unapplied database migrations. Verify the user and session tables exist and that cookies are not blocked by cross-origin settings.