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 to development, but overridden in production.

  • BETTER_AUTH_SECRET โ€” Secret key used for encrypting auth tokens. You can generate one using openssl 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: .env values are type-checked at runtime using Zod via src/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 dialect if you're switching off Turso or Postgres.
  • Customize out if 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, and pnpm dev are set up for local development with Turso and Drizzle.
  • pnpm dev runs 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 jq or sqlite-utils? Add it to devShell.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)

Next Steps