---
title: "Neon"
description: "Give every run its own isolated Neon Postgres branch, wired into the sandbox through .trevize/settings.json."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.trevize.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Neon

Connecting **Neon** lets Trevize provision an **isolated Postgres branch for
every run**. Each run gets a fresh read-write branch of your Neon project — so
agents (and previews) work against real data without touching production — and
the branch is torn down when the run's sandbox is cleaned up.

## Connect Neon

1. **Add a Neon API key**

   In integration settings, paste a **Neon API key** (it starts with `napi_`).
   For security, prefer a **project-scoped** key (Neon console → Organization
   settings → API keys); account-wide keys work too but grant access to all
   projects. For a project-scoped key, also enter its **Project ID**.

2. **Choose the project and branch**

   Once connected, pick the **project** runs should branch from and, optionally, a
   **parent branch** (each run branches from it; leave empty to use the project's
   default). Save the configuration.

## Use it in a repository

Tell a repository to use Neon by declaring the resource in its
[`.trevize/settings.json`](/configuration), mapping your app's database
environment variable to the one Trevize provides:

```json
{
  "resources": {
"neon": {
  "env": {
    "DATABASE_URL": "NEON_DATABASE_URL"
  }
}
  }
}
```

For each run, Trevize provisions a branch and injects `NEON_DATABASE_URL` (the
branch's connection string) and `NEON_BRANCH_ID` into the sandbox. The mapping
above sets your app's `DATABASE_URL` from `NEON_DATABASE_URL`. The settings page
shows, per repository, whether the resource is **configured** and the env mapping
in effect.

> **Let an agent wire it up**
>
> The Neon settings page can copy a setup prompt that detects your app's actual
> Postgres environment variable and generates the correct `resources` block for
> you. See [Resources configuration](/configuration) for the details.

Source: https://docs.trevize.dev/integrations/neon/index.mdx
