The `auth` package provides the command-line interface (CLI) for Better Auth, an authentication solution. This CLI helps developers manage database schemas required for Better Auth's core functionality and its plugins. As of April 2026, the current stable version is 1.6.8, with a 1.7.0-beta.2 also available, indicating active development with frequent patch and minor releases, alongside pre-releases for upcoming features. Key differentiators include its ability to generate ORM-specific schemas for adapters like Prisma and Drizzle, as well as an SQL file for its built-in Kysely adapter. It also offers commands for initializing a project, applying migrations, and securely generating secret keys for Better Auth instances.
npm install authNo compatibility data collected yet for this library.
Demonstrates how to initialize a Better Auth project, generate the necessary database schema, and generate a secret key using the `npx auth@latest` CLI commands.
Update code handling the `enableTwoFactor` response to account for the new discriminated `method` field and potentially pass the `method` parameter when enabling 2FA.
Run `npx auth@latest generate` followed by your ORM's migration command (e.g., `npx prisma migrate dev` for Prisma, `npx drizzle-kit push:pg` for Drizzle) or `npx auth@latest migrate` if using the built-in Kysely adapter.
Always invoke the functionality using `npx auth@latest <command>` or by calling the globally installed `auth` executable. Do not attempt to `import { generate } from 'auth'` or similar.After running `npx auth@latest generate`, execute your ORM's migration command (e.g., `npx prisma migrate dev` or `npx prisma db push` for Prisma, `npx drizzle-kit push:pg` for Drizzle). The `npx auth@latest migrate` command is only for the built-in Kysely adapter.
Apply the schema migration by running `npx auth@latest generate` and then your ORM's specific migration command (e.g., `npx prisma migrate dev` or `npx drizzle-kit push:pg`).
The `auth` package is a CLI tool. Execute its commands using `npx auth@latest generate` (or other commands) from your terminal, not by importing into your JavaScript/TypeScript code.
Ensure your Better Auth server-side configuration includes the `otpOptions.sendOTP` function to handle sending OTPs to users. This error typically occurs after upgrading to `better-auth` v1.7.0-beta.0 or later and using `enableTwoFactor({ method: "otp" })`.No dependency data recorded yet.