# Deploy Codra With Neon

> Set up a serverless Neon PostgreSQL database and connect Codra to it through Cloudflare Hyperdrive or direct connection pooling.

Canonical: https://codra.run/docs/neon
Last updated: 2026-11-01

<h2 id="setup">Neon Setup</h2>

Neon provides a serverless PostgreSQL experience that is perfect for Cloudflare Workers. It scales to zero when not in use and provides instant branching.

### 1. Create a Project

New to Neon? <a href="https://go.devarshi.dev/neon-free" target="_blank" rel="noopener noreferrer" className="text-primary hover:underline">Sign up here</a> to get free credit. Log in to the <a href="https://go.devarshi.dev/neon-free" target="_blank" rel="noopener noreferrer" className="text-primary hover:underline">Neon Console</a> and create a new project. Choose a region close to your main user base (or your Cloudflare Worker's primary region).

![Neon console showing the create project flow](https://codra.run/assets/docs/docs-neon-create-project.png)
_Create a Neon project in the closest supported region for your deployment._

### 2. Get your Connection String

Once the project is created, Neon will provide a connection string. It will look like this:

```text
postgresql://neondb_owner:npg_...-pooler.ap-southeast-1.aws.neon.tech/neondb?sslmode=require
```

![Neon dashboard showing the pooled database connection string](https://codra.run/assets/docs/docs-neon-connection-string.png)
_Copy the pooled connection string from the Neon project dashboard._

> **INFO:** 
> Always use the <strong>pooled</strong> connection string (the one with <code>-pooler</code> in the hostname) for serverless environments.

<h2 id="hyperdrive">Cloudflare Hyperdrive</h2>

Hyperdrive makes your existing regional databases feel like they're distributed. it maintains a pool of connections to your database from Cloudflare's network, reducing connection overhead.

### 1. Create a Hyperdrive Config

In your Cloudflare Dashboard, go to **Workers & Pages > Hyperdrive** and create a new configuration using your Neon connection string.

Alternatively, use wrangler:

```shell
npx wrangler hyperdrive create codra-db --connection-string="postgresql://user:pass@host/db?sslmode=require"
```

![Cloudflare dashboard showing a created Hyperdrive configuration](https://codra.run/assets/docs/docs-hyperdrive-created-console.png)
_Create a Hyperdrive configuration using the Neon pooled connection string._

### 2. Get the Hyperdrive ID

Note the ID provided by Cloudflare. You will need to add this to your `wrangler.jsonc`.

<h2 id="connection">Connecting Codra</h2>

Once you have your Neon database and Hyperdrive ID, update your configuration.

### Update wrangler.jsonc

Add your Hyperdrive ID to the configuration:

```jsonc
"hyperdrive": [
  {
    "binding": "HYPERDRIVE",
    "id": "35b282fa80f24e67adfda063c3a839d1" // Your ID here
  }
]
```

### Set Database Secret

Set the `DATABASE_URL` secret for your production worker. If using Hyperdrive, Cloudflare will automatically route connections through the pooler when you use the binding, but you still need to provide the connection string to the application logic.

```shell
npx wrangler secret put DATABASE_URL
```

When prompted, enter your Neon connection string.

> **INFO:** 
> For local development, you can paste your Neon connection string directly into <code>.dev.vars</code> as <code>DATABASE_URL</code>.

> **WARN:** 
> Dashboard-managed provider API keys are stored encrypted in PostgreSQL, so database backups can contain encrypted provider credentials. Keep <code>LLM_CONFIG_ENCRYPTION_KEY</code> stable across deploys; changing it makes saved provider keys undecryptable.

  
    <p className="text-base font-medium text-foreground">Next: Configuration</p>
    <p className="text-sm text-foreground/80 mt-1">Tune repository review behavior and model selection.</p>
  
  [Configuration](https://codra.run/docs/configuration)
