Step-by-step guides for self-hosting and getting started with your framework.
Click a guide to open it. The URL will update to guides#link-of-guide so you can share or bookmark.
Deploy the studio on your own server from scratch
Full setup and customization with App Router
Hono, Express, Elysia, SvelteKit, and more
Config options: access, metadata, theme, tools, events
Installation, self-hosting, and Better Auth docs
Self-hosting runs the studio inside your app so it’s available at a URL you choose (e.g. /api/studio or /admin). Only people who pass your access rules (roles or allowlisted emails) can open it. The studio is served by your framework, so it works in production without a separate process.
Before adding the studio you need:
auth exported from e.g. lib/auth.ts or src/auth.ts).Step 1: Install the package
Use a regular dependency (not dev) so the studio is available in production.
Step 2: Generate the config file
From your project root, run the init command. It will create studio.config.ts (or studio.config.js) and, for some frameworks, the route file.
Step 3: Point config to your auth
Open studio.config.ts and set auth to your Better Auth instance (e.g. import { auth } from "./lib/auth").
Step 4: Mount the studio in your app
Depending on your framework, you mount the handler on a path that matches basePath in config (default /api/studio). For exact code per framework, see the Next.js guide below or the Self-hosting page.
In studio.config.ts you can change:
basePath – URL path where the studio is served (e.g. /admin). Your route must match this.access.roles – Only users with these Better Auth roles can open the studio.access.allowEmails – Only these emails can open the studio (ignored if roles is set).metadata – Title, logo, theme (dark/light/auto), and other UI options.For every option, see the Customize the studio guide.
You need a Next.js app (App Router) with Better Auth already set up:
lib/auth.ts)If you don’t have a project yet:
Then add Better Auth and your database adapter (see Better Auth docs). You should end up with something like src/lib/auth.ts (or lib/auth.ts) exporting auth and an API route for auth (e.g. app/api/auth/[...all]/route.ts).
Install as a regular dependency so it runs in production:
For local-only use you can use pnpm add -D better-auth-studio and run pnpm better-auth-studio start instead of embedding the route.
Run the init command to generate the config and, for Next.js, the API route file:
It creates studio.config.ts at the project root and app/api/studio/[[...path]]/route.ts. The route file should look like this:
If your config lives elsewhere, change the import (e.g. from "@/studio.config" or from "../../studio.config").
Open http://localhost:3000/api/studio (or the basePath you set in studio.config.ts). You’ll be asked to sign in; only users who match your access config can use the studio.
studio.config.ts set basePath: "/admin" (or another path).Then move the route to app/api/admin/[[...path]]/route.ts so the route path matches basePath.access.roles (e.g. ["admin"]) or access.allowEmails in the config. See the Customize the studio guide.metadata.title, metadata.logo, metadata.theme in config.Same flow: install better-auth-studio, run pnpx better-auth-studio init to get studio.config.ts, then mount the framework adapter on the path that matches basePath (e.g. /api/studio).
pnpm add better-auth-studiopnpx better-auth-studio init – creates studio.config.ts. Point it at your auth.better-auth-studio/hono, better-auth-studio/express) and mount the handler on basePath.better-auth-studio/honobetter-auth-studio/expressbetter-auth-studio/elysiaFor exact code per framework, see the Self-hosting page and pick your framework in the tabs.
All customization lives in studio.config.ts: auth, basePath, access, metadata, and optionally tools, events, lastSeenAt, ipAddress. Below is what each does and how to set it.
URL path where the studio is served. Default /api/studio. Your app must serve the handler on this path.
roles – Array of Better Auth role names (e.g. ["admin"]).allowEmails – Array of emails allowed when not using roles.sessionDuration – Studio session length (e.g. seconds).secret – Secret for signing the studio session; set in production.title, logo, favicontheme – "dark" | "light" | "auto"colors – primary, secondary, accentcompany – name, website, supportEmailfeatures – Toggle users, sessions, organizations, analytics, tools, securitylinks – [{ label, url }]Use tools.exclude with ids like test-oauth, health-check, run-migration to hide them from the Tools page.
Optional event ingestion for the Events dashboard: events.enabled, client / clientType (prisma, drizzle, sqlite, etc.), include / exclude event types, liveMarquee.
lastSeenAt – Updates a “last seen” column on the user at sign-in. ipAddress – Optional IP geolocation (ipinfo, ipapi, or MaxMind file) for Events/Sessions location.