Files
better-auth/packages/cli
Alex Yang 73ca92ee8c fix(cli): warn when old @better-auth/cli is used with better-auth v1.5.x+
Closes #8622

When the old @better-auth/cli detects that better-auth >= 1.5.0 is
installed, it now prints a warning directing users to the new `auth` CLI
(`npx auth@latest`). This prevents unexpected behavior from the old CLI
generating incorrect schemas for v1.5.x projects.

Uses `createRequire` from the user's CWD to resolve better-auth's
package.json and `semver.gte` for version comparison. Uses `chalk` for
terminal colors (consistent with the rest of the CLI). Silently skips
the check if better-auth is not installed.
2026-03-16 13:22:20 -07:00
..
2026-03-02 02:33:29 +09:00
2025-11-29 09:18:23 -08:00

Better Auth CLI

Better Auth comes with a built-in CLI to help you manage the database schema needed for both core functionality and plugins.

Init

The CLI includes an init command to add Better Auth to your project.

npx @better-auth/cli@latest init

Generate

The generate command creates the schema required by Better Auth. If you're using a database adapter like Prisma or Drizzle, this command will generate the right schema for your ORM. If you're using the built-in Kysely adapter, it will generate an SQL file you can run directly on your database.

npx @better-auth/cli@latest generate

Migrate

The migrate command applies the Better Auth schema directly to your database. This is available if youre using the built-in Kysely adapter. For other adapters, you'll need to apply the schema using your ORM's migration tool.

npx @better-auth/cli@latest migrate

Secret

The CLI also provides a way to generate a secret key for your Better Auth instance.

npx @better-auth/cli@latest secret

License

MIT