new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Better Auth · Concepts · all subjects

cli

19 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

CLI migrate command for database migrations

The Better Auth CLI includes a migrate command that checks your database and prompts you to add missing tables or update existing ones with new columns. This is only supported for the built-in Kysely adapter. For other adapters like Prisma or Drizzle, use the generate command to create the schema and handle migration through your ORM. Run with: npx auth@latest migrate

CLI generate command for database schema

The generate command creates the schema required by Better Auth. If using a database adapter like Prisma or Drizzle, it generates the right schema for that ORM. If using the built-in Kysely adapter, it generates an SQL file you can run directly on your database. Run with: npx auth@latest generate

generate command options

The generate command accepts three options: --output (where to save the generated schema; for Prisma it saves to prisma/schema.prisma, for Drizzle to schema.ts in project root, for Kysely to schema.sql in project root), --config (path to Better Auth config file; defaults to searching for auth.ts in ./, ./utils, ./lib, or these directories under src), --yes (skip confirmation prompt and generate schema directly).

CLI migrate command for Kysely databases

The migrate command applies the Better Auth schema directly to your database. This is only available when using the built-in Kysely adapter. For other adapters, you must apply the schema using your ORM's migration tool. Run with: npx auth@latest migrate

migrate command options

The migrate command accepts two options: --config (path to Better Auth config file; defaults to searching for auth.ts in ./, ./utils, ./lib, or these directories under src), --yes (skip confirmation prompt and apply schema directly).

PostgreSQL schema migration with migrate command

The migrate command automatically detects your configured search_path and creates tables in the correct schema when using PostgreSQL with a non-default schema.

CLI init command for project initialization

The init command initializes Better Auth in your project. Run with: npx auth@latest init

init command options

The init command accepts five options: --name (name of your application; defaults to name property in package.json), --framework (framework your codebase uses; currently only Next.js supported), --plugins (plugins you want to use; specify multiple by separating with comma), --database (database to use; currently only SQLite supported), --package-manager (package manager to use; currently npm, pnpm, yarn, bun supported; defaults to the manager used to initialize the CLI).

CLI upgrade command for dependencies

The upgrade command updates older better-auth and official @better-auth/* dependencies to the version of the CLI being run. Dependencies at the same or a newer version are left unchanged. Run with: npx auth@latest upgrade

upgrade command options

The upgrade command accepts two options: --cwd (project directory containing package.json to update; defaults to current directory), --yes (skip confirmation prompt and install updates directly).

CLI info command for diagnostic information

The info command provides diagnostic information about your Better Auth setup and environment. It is useful for debugging and sharing when seeking support. Run with: npx auth@latest info

info command output details

The info command displays: System (OS, CPU, memory, Node.js version), Package Manager (detected manager and version), Better Auth (version and configuration with sensitive data auto-redacted), Frameworks (detected frameworks like Next.js, React, Vue, etc.), Databases (database clients and ORMs like Prisma, Drizzle, etc.).

info command options

The info command accepts two options: --config (path to Better Auth config file), --json (output as JSON for sharing or programmatic use).

info command examples

Examples for info command: Basic usage: npx auth@latest info. Custom config path: npx auth@latest info --config ./config/auth.ts. JSON output: npx auth@latest info --json > auth-info.json

info command redacts sensitive data

Sensitive data like secrets, API keys, and database URLs are automatically replaced with [REDACTED] in info command output for safe sharing.

CLI secret command for key generation

The CLI provides a way to generate a secret key for your Better Auth instance. Run with: npx auth@latest secret

CLI resolves imports including path aliases and virtual modules

The CLI resolves most imports for you, including tsconfig.json path aliases (including SvelteKit's $lib) and stubbed framework virtual modules ($env/*, $app/*, cloudflare:workers, Vite assets like ?raw). For SvelteKit, run svelte-kit sync first so .svelte-kit/tsconfig.json exists.

CLI module resolution limitation

A few module types cannot load outside their bundler and will cause errors with the CLI, such as .svelte components or import.meta.glob. Keep those out of your config file's import graph to avoid the 'Cannot find module X' error.

Better Auth installation via npm

Better Auth can be installed using the npm command: npm i better-auth

Give your agent this brain