Skip to content
Dinvolt
Esc
↑↓navigate↵open⌘Jpreview
On this page

Administrators and users

For Admin panel only projects, the login is /, the home page is /dashboard, and other panel pages omit the /admin prefix. The proxy matches /dashboard/:path*, /users/:path* and /settings/:path*. Components use @/components and @/components/ui. API endpoints such as /api/admin/users/export keep their paths. Examples below use the combined public website + admin panel layout; generated standalone guides use the app’s actual paths.

Create the first administrator

If you skipped this step in setup, use an interactive terminal:

npm run auth:create-admin -- --email admin@example.com --name Admin
bun run auth:create-admin --email admin@example.com --name Admin
pnpm run auth:create-admin --email admin@example.com --name Admin
yarn run auth:create-admin --email admin@example.com --name Admin

The command checks the auth tables and creates a random 12-character initial password. Save the password when it appears: the command displays it once and does not save it to a file. It works immediately and does not expire automatically.

The command preserves existing accounts. A duplicate email is rejected without changing its role or password. Missing tables stop creation; follow the matching database migration instructions before retrying.

Staging and production

Use the command for the intended environment:

npm run auth:create-admin:staging -- --email admin@example.com --name Admin
bun run auth:create-admin:staging --email admin@example.com --name Admin
pnpm run auth:create-admin:staging --email admin@example.com --name Admin
yarn run auth:create-admin:staging --email admin@example.com --name Admin
npm run auth:create-admin:production -- --email admin@example.com --name Admin
bun run auth:create-admin:production --email admin@example.com --name Admin
pnpm run auth:create-admin:production --email admin@example.com --name Admin
yarn run auth:create-admin:production --email admin@example.com --name Admin

Only selected environments receive these scripts. Commands without a suffix always target development. Provide the target environment’s database credentials and auth configuration; selecting a database does not switch auth secrets or origins.

Wizard-created credentials

The create/setup wizard skips environments that already have an administrator. Each newly created administrator gets a different password; existing users are never promoted or reset.

For development, a successful wizard creation saves these private defaults in the selected ignored dotenv file:

DEV_ADMIN_USER=admin@example.com
DEV_ADMIN_PASSWORD=your-generated-development-password

They prefill the local development login form. You still click Sign in to authenticate. Vercel deployments and production builds/servers never prefill these values.

Staging/production passwords appear in the interactive wizard without being saved locally. Non-interactive creation/setup requires a private admin-output file; see the CLI reference.

If a write fails, inspect the account before retrying: an interrupted operation can be partial.

Manage users

Find an account

Open /admin/users. Search by name, email, or ID, filter by User/Admin role, and change the page size or sort order.

Filters and pagination live in the URL, so Back/Forward restores the list. Existing rows remain visible during background refreshes. Each administrator/filter combination stays fresh in the browser for one minute.

The API rechecks the session, ban state, and exact admin role on every request. It returns display fields; passwords, tokens, accounts, and sessions stay out of responses.

Create a user

  1. Click Create user.
  2. Enter a name, email, password, and role.
  3. Submit the form.

The form uses Better Auth’s Admin plugin for authorization and password hashing. Duplicate emails show a validation error. Successful creation refreshes the list while preserving filters and the acting administrator’s session.

This flow does not send an email. Share initial access through your application’s chosen process.

Edit an account

Open a user row, then click Edit user to change the name or email. The detail page includes account status and ban details when relevant.

Saving updates the detail, list, breadcrumb, and current administrator menu when applicable. Role, ban, and password management need separate controls.

These built-in user flows use the existing auth schema and need no extra migration. See admin tables for query state and export behavior.

Was this page helpful?