# Next.js boilerplate with Neon

> Serverless Postgres with copy-on-write database branching. It ships an HTTP driver for one-shot queries and a pooled connection for route handlers that need a session. It also adds a read-only db-inspector agent, and a Bash guard that keeps migrations off the pooler.

Serverless Postgres you can branch like git, with a driver built for cold starts.

- **Category:** Database
- **Pricing:** Free plan: up to 100 projects, each with 100 CU-hours a month and 0.5 GB of storage. Launch and Scale have no monthly minimum: you pay per CU-hour ($0.106 on Launch) plus $0.35 per GB-month of storage.
- **Best for:** Teams that want plain Postgres plus a throwaway database per pull request, running on Vercel or another serverless host where connections are scarce.
- **Requires:** orm
- **Conflicts with:** supabase
- **Vendor docs:** https://neon.com/docs

## Trade-offs

- Standard Postgres. ORMs and psql work unchanged, with no custom query layer to learn.
- Branching is copy-on-write, so a preview branch of a 20 GB database only adds storage for what the branch changes.
- Compute scales to zero after 5 idle minutes and wakes in a few hundred milliseconds. On low-traffic previews that shows up as a slow first request.
- Database only. No auth, storage, realtime or generated API. Pair it with Better Auth or Clerk. Supabase bundles those.
- Two connection strings to keep straight (pooled and direct). Point a migration at the pooled one and it fails in confusing ways.

## Known fixes it ships

- [A Neon branch per preview deployment](https://agenticboilerplate.com/cookbook/neon/branch-per-preview-deployment): Preview deploys that share the production database corrupt it or lie to you. Give every preview its own copy-on-write Neon branch, wired to the deployment's environment variables.
- [Neon cold starts, where the half second goes and what to do about it](https://agenticboilerplate.com/cookbook/neon/cold-start-latency): Scale-to-zero means an idle branch takes roughly 500 ms to wake, and a serverless function adds its own cold start on top. How to measure the parts and fix the ones that matter.
- [Connection exhaustion on serverless Postgres, and how to actually fix it](https://agenticboilerplate.com/cookbook/neon/connection-exhaustion-in-serverless): Serverless does not queue requests on a pool, it creates pools. Here is the arithmetic, the four real causes, and the fix for each.
- [Local Postgres with the Neon serverless driver, no Neon account](https://agenticboilerplate.com/cookbook/neon/local-postgres-without-a-neon-account): The Neon driver speaks HTTPS and WebSocket, not the Postgres wire protocol. A small local proxy plus two neonConfig settings let it run against a Postgres on your laptop, with no code fork.
- [Running migrations on Vercel without a half-applied schema](https://agenticboilerplate.com/cookbook/neon/migrations-on-vercel): Vercel has no migration step, so people add one in the wrong place. Where migrations belong in the build, why the direct URL is mandatory, and how to deploy a breaking change in two safe halves.
- [Neon's pooled and unpooled connection strings, and which one to use where](https://agenticboilerplate.com/cookbook/neon/pooled-vs-unpooled-connections): The -pooler host and the direct host are not interchangeable. Runtime queries need the pooler; migrations, advisory locks and session state need the direct endpoint.

## Generate it

[Build a repo with Neon](https://agenticboilerplate.com/build?b=neon)

---

Agentic Boilerplate: A Next.js repo your agent already knows. Free during launch, then $99 once.

- Site map for agents: https://agenticboilerplate.com/llms.txt
- Public API: https://agenticboilerplate.com/openapi.json
- Contact: agenticstudio@gmail.com
