This page gets a local admin running with the smallest complete hooks.server.ts. The handler reads your schema once when it is created and serves the admin below /admin by default.
1. Install
Install the ORM package and its runtime dependencies in the application as well. For Prisma, run prisma generate after changing the schema. For Drizzle, keep exporting the same table schema object that your application uses.
2. Prisma quick start
The Prisma schema is read from ./prisma/schema.prisma by default. If the app starts from another working directory or uses a non-standard schema location, set prismaSchemaPath explicitly:
Run the app and open http://localhost:5173/admin:
There are no src/routes/admin files to add. The authCheck in the first example assumes an earlier auth hook has populated event.locals.session; see Authentication.
3. Drizzle quick start
Use the dedicated subpath so a Drizzle-only app does not import the Prisma adapter:
schema must be the object containing your Drizzle table exports (including relations() exports when your schema uses them). Model keys in models are the schema export keys, such as users, rather than Prisma-style User. If the dialect cannot be inferred, pass dialect: 'postgresql' | 'mysql' | 'sqlite'.
For SQLite many-to-many writes, the current adapter expects better-sqlite3’s synchronous transaction API. PostgreSQL and MySQL use async transactions; async SQLite drivers are not supported for those writes in this version.
Existing authentication
Compose your auth hook before the admin hook:
First-admin checklist
- The schema/client exists and is generated.
-
authCheckdenies an anonymous request and allows an administrator. -
models[].scopeis present for tenant data. -
/adminworks locally and a create/update/delete has been tested with a non-production database. - CSRF and sensitive-field defaults have not been disabled casually.
Continue with Model Configuration, Relations, or Troubleshooting.