---
title: "Set Up Environment Variables and the Database"
description: "Install dependencies with pnpm, fill in the Zod-validated environment variables in apps/web/.env and create the PostgreSQL schema for your Nuxt app."
canonical_url: "https://nuxtstarterkit.com/docs/getting-started/setup"
---

> Index of every page on this site: [llms.txt](https://nuxtstarterkit.com/llms.txt)

<steps level="3">

### Install dependencies

Run all commands from the repository root:

```bash
pnpm install
```

This also runs `nuxt prepare` in `apps/web`, which generates the types.

### Setup environment variables

Copy `apps/web/.env.example` to `apps/web/.env` and fill in the values. The Nuxt CLI reads this file in development and during the build.

```bash
cp apps/web/.env.example apps/web/.env
```

Every layer declares its environment variables as [Zod](https://zod.dev/) schemas in the `runtimeConfig` of its `nuxt.config.ts`. When a required value is missing, the server refuses to start and lists the missing values (error `NUXT_E8014`). At runtime only the type, whether a value is required and enum values are checked, not refinements like `.min()` or `.url()`.

Required environment variables:

- `NUXT_BETTER_AUTH_SECRET` - Secret for better-auth, at least 32 random characters (e.g. `openssl rand -base64 32`)
- `NUXT_PRIVATE_DATABASE_URL` - PostgreSQL connection string
- `NUXT_PUBLIC_BASE_URL` - Your app URL (e.g., `http://localhost:9009` for local dev). better-auth uses it as its base URL.
- `NUXT_PRIVATE_POLAR_ACCESS_TOKEN` - Polar access token
- `NUXT_PRIVATE_EMAIL_CONTACT` - Address that receives contact form submissions
- `NUXT_PRIVATE_FROM_EMAIL` - Sender address of all emails

Optional:

- `NUXT_PRIVATE_POLAR_ORGANIZATION_ID` - Your Polar organization ID
- `NUXT_PRIVATE_POLAR_SERVER` - `sandbox` (default) or `production`
- OAuth credentials for social login (Google, GitHub), see [Authentication](https://nuxtstarterkit.com/docs/authentication)
- Email provider settings, see [Emails](https://nuxtstarterkit.com/docs/emails)
- Storage settings, see [Images](https://nuxtstarterkit.com/docs/images)

<note>

Never read `process.env` in app code. Add new values as Zod schemas to the `nuxt.config.ts` of the layer that owns them and to `apps/web/.env.example`, then read them with `useRuntimeConfig()`.

</note>

### Create database schema

Apply the database migrations:

```bash
pnpm db:migrate
```

The migrations are part of the repository. Run `pnpm db:generate` only after you change a schema file, see [Database](https://nuxtstarterkit.com/docs/database).

### Start the development server

Start the development server for the web app:

```bash
pnpm dev
```

You can now access your app at `http://localhost:9009`.

### Polar

Nuxt Starter Kit uses [Polar](https://polar.sh/) to accept payments, see [Payments](https://nuxtstarterkit.com/docs/payments) for more information.

This starter kit is designed to support subscriptions (free & Pro) and lifetime deals. You should configure three products in Polar:

- Pro Plan (yearly subscription)
- Pro Plan (monthly subscription)
- Lifetime Deal (one-time payment)

<note>

Any other product constellation needs adjustments in the `apps/web/layers/payment` layer and other parts of the codebase.

</note>
</steps>

## Sitemap

See the full [sitemap](https://nuxtstarterkit.com/sitemap.md) for all pages.
