Configuration
Key configuration files you might want to customize for your setup or deployment.
.env
Your .env file is generated dynamically during setup. It contains the environment variables needed for the backend, auth, and local dev tooling.
Example:
NODE_ENV=development
BETTER_AUTH_SECRET=abcd1234...
BETTER_AUTH_URL=https://localhost:3000
Turso
If you choose to use Turso as your database, it will include:
TURSO_DATABASE_URL=http://127.0.0.1:8080
TURSO_AUTH_TOKEN= # not needed for local development
Docker + Postgres
If you choose Docker + Postgres, it will include:
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/matt-init_db
POSTGRES_DB=matt_init_db
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_PORT=5432
What each of these does:
-
NODE_ENVโ Usually set todevelopment, but overridden in production. -
BETTER_AUTH_SECRETโ Secret key used for encrypting auth tokens. You can generate one usingopenssl rand -hex 32. -
BETTER_AUTH_URLโ The base URL of your app, used by BetterAuth for redirects and cookie handling. -
TURSO_DATABASE_URLโ The URL for your local Turso database instance. -
TURSO_AUTH_TOKENโ Not needed for local development, but required in production -
DATABASE_URLโ The connection string for your Postgres database. -
POSTGRES_DBโ The name of your Postgres database. -
POSTGRES_USERโ The username for your Postgres database. -
POSTGRES_PASSWORDโ The password for your Postgres database. -
POSTGRES_PORTโ The port your Postgres database is running on (default is 5432).
Note:
.envvalues are type-checked at runtime using Zod viasrc/lib/env.ts. Missing or invalid values will cause the app to fail fast during boot.
drizzle.config.ts
Handles Drizzle ORM configuration for migrations and schema paths.
Things you might tweak:
- Change the
dialectif you're switching off Turso or Postgres. - Customize
outif you want migrations in a different folder
package.json
Everything here is ready to go, but worth knowing:
- Scripts like
pnpm db:push,pnpm db:migrate,pnpm db:generate,pnpm db:studio, andpnpm devare set up for local development with Turso and Drizzle. pnpm devruns both the Next.js dev server and a Turso dev DB concurrently (if backend is enabled).
src/lib/env.ts
This handles env var validation using Zod. If you add new environment variables, you should update this schema to match. Check out the Zod documentation for more details on how to modify it.
const EnvSchema = z.object({
NODE_ENV: z.string(),
BETTER_AUTH_SECRET: z.string(),
BETTER_AUTH_URL: z.string(),
});
src/lib/db/schema/
This is where your Drizzle schemas live. If you're building out your app's models, this is where to do it. It already includes basic user, session, and account tables used by BetterAuth.
flake.nix / nix/devShell.nix
Only relevant if you enabled Nix. These define your development shell and toolchain.
- Want to add a CLI tool like
jqorsqlite-utils? Add it todevShell.nix. - Want to pin a different version of Node or PNPM? Adjust it here.
eslint.config.mjs
Based on @antfu/eslint-config, with extra rules for filename casing, import sorting, and strict formatting. If you need to tweak a rule, this is where it lives.
.vscode/
If you opted in, this includes:
- Recommended extensions (
extensions.json) - Project-specific settings like formatting on save, auto-imports, etc. (
settings.json)