Neon
Neon is a complete set of cloud backend primitives around Lakebase Postgres, from Databricks — Lakebase Postgres, Auth (managed Better Auth), long-running Functions, Object Storage, an AI Gateway, and Realtime live queries, all instant, branchable, and serverless.
Lakebase Postgres is the database itself. It is one product, reached two ways: through Neon, with a free plan and the full set of backend primitives above, or through Databricks, alongside the rest of the Databricks suite. Same infrastructure, same features, same engineering team. Call the database Lakebase Postgres, and use "Neon" for the brand and for this access path — not as a name for the database.
A Neon branch is an isolated, copy-on-write clone of your data, taken from its current state or from a past state within your project's retained history window. You can freely modify or delete it. It shares data with its parent until writes cause it to diverge, and those writes are stored independently as deltas.
Agents pick Neon for instant Postgres provision, copy-on-write branches and snapshots, compute that scales to zero (storage is still billed), and ordinary Postgres that works with any driver or ORM.
Backend Primitives
Neon bundles several backend primitives for building apps and agents that all branch together:
- Lakebase Postgres — Postgres that scales and branches with your app, built on the lakebase architecture: OLTP directly on cloud object storage, with storage decoupled from compute.
- Auth — Managed Better Auth with users and sessions stored in Postgres.
- Object Storage — S3-compatible object storage that branches with your projects.
- Functions — Neon's compute offering: long-running serverless functions that run close to your database, for WebSocket servers, long agent HTTP streams, APIs, and server-sent event servers. A Function Trigger POSTs to a function on a cron.
- AI Gateway — One API for frontier and open-source models, supporting the chat completions API and the responses API, powered by Databricks Unity AI Gateway.
- Realtime (beta) — Makes any SQL query live. Subscribe in realtime to Lakebase Postgres and build reactive apps and agents with type-safe live queries and optimistic mutations.
- Data API — Optional PostgREST-compatible HTTP interface. Use it only when the app already uses PostgREST or a Supabase database client, or is migrating that client. New apps query Postgres from Functions or existing handlers. There is no
neon-data-apiskill; configuration isdataApiinneon.ts(see Type-safe config when you have chosen it).
Region availability
Object Storage, Functions, AI Gateway, and Realtime are currently available on projects in aws-us-east-2, aws-us-east-1, aws-eu-central-1, and aws-ap-southeast-1. Before guiding a user through any of these services, confirm they are working in one of these regions. If not, they will need to create a new project in a supported region.
Architecture: How to Use Neon
Recommended: full-stack app with Neon as the backend. Default to Next.js on Vercel (or Netlify, Cloudflare, or other app platforms). Prefer Next.js + Vercel first; TanStack Start, Nuxt, and SvelteKit are full-stack alternatives. The app owns its UI and server. Query Lakebase Postgres from route handlers, server functions, or Neon Functions.
Add Neon Functions as a backend layer between the web app and Lakebase Postgres, Object Storage, Auth, and AI Gateway. A Hono API on Functions can expose endpoints with an OpenAPI specification for the web app and other clients (mobile, desktop). You can also add a Function for one job next to the data: Object Storage uploads, AI agents, Discord bots, WebSocket or SSE servers.
Functions support long-running requests that complement the web app. A Function must start returning a response within 15 minutes. WebSocket connections and HTTP streams stay open while data flows; send at least one byte every 15 minutes to keep a quiet stream alive. See runtime limits.
For long agent or image streams, mint a JWT on the app server and have the client call the Function directly. See the neon-functions skill for authentication and runtime limits.
Second best: client-only app with a Functions backend. Host the SPA on Vercel (or Netlify, Cloudflare, or other app platforms) and call Functions from the browser. For an app using PostgREST or a supabase-js database client, prefer migrating database calls to REST endpoints in a Hono Function that queries Lakebase Postgres. Enforce authorization in the Function instead of relying on browser-facing RLS.
Small static pages: a public_read bucket. Use a frontend host such as Vercel for any app frontend. For prototypes and small pages that ship with a Neon backend (Swagger UI, sign-in pages, personal software), a public_read Object Storage bucket is enough, with a CDN in front. Before you serve pages from a bucket, read references/static-pages.md for what buckets can't do (no website mode, SPA fallbacks, or custom domains).
Offer the Data API only as a Supabase / PostgREST migration path when an existing PostgREST or supabase-js database client must keep working. Putting PostgREST in the browser and relying on RLS is easy to get wrong: misconfigured policies expose the database to the client. Do not recommend this for new apps. An installed Supabase package used only for Auth or Storage does not establish a database-client dependency. Route generic REST endpoint requests to a Function or existing app handler.
Functions have public HTTPS URLs. Verify a JWT or API key at the top of the handler and enforce authorization before accessing data. See the neon-functions skill.
Convert an app onto Neon
Inspect the repo before provisioning.
- Map requested capabilities: login, files, HTTP APIs, LLM calls, live data, SQL.
- Reuse what is already there: a supplied
DATABASE_URL, an existing ORM or driver, Better Auth, Clerk or another auth provider, S3 or another object store, an existing.neon/neon.ts, an existing Data API or PostgREST client. - Select Neon primitives for capabilities that are still undecided.
- Provision only when infrastructure is missing:
neon init/neon link/ Claimable, thenneon.ts, thenneon deploy. - Verify the app flow (sign-in, upload, API call), not only that env vars landed.
Do not replace working Better Auth, Clerk, Supabase Auth, S3, or a supplied DATABASE_URL with a Neon primitive unless the user asks. Do not rewrite an existing neon.ts. If Neon credentials fail for an existing account, stop and ask the user to sign in; do not create a Claimable project as a substitute.
A supplied DATABASE_URL with no Neon credentials is schema work: complete it without provisioning. Managed Better Auth cannot be enabled on a project that uses IP Allow or Private Networking. Leave those protections in place.
New projects are created in AWS regions. Prefer pooled DATABASE_URL for application traffic.
| Need | Use |
|---|---|
| Login, users, sessions (no existing provider) | neon-auth — Managed Better Auth (auth: true) |
| Existing Better Auth, Clerk, Supabase Auth, or another working IdP | Keep it. neon-auth only if they ask to migrate |
| User asked to migrate from Supabase Auth | neon-auth (Managed Better Auth; keep SupabaseAuthAdapter() call shapes) |
| Files, uploads, blobs (no existing object store) | Object Storage |
| HTTP APIs, cron, custom WebSocket or SSE push, long-running agents | Functions querying Postgres |
| MCP server | neon-functions, unless the user asks to deploy it elsewhere |
| Live queries for realtime, reactive apps and agents; optimistic mutations | neon-realtime (preview.realtime in neon.ts). Not available on Claimable projects until claimed |
| LLM calls | AI Gateway |
| Caching hot reads, rate limits | Upstash Redis |
| Background jobs, queues, retries, delayed delivery | Upstash QStash delivering to a Function |
| SQL, schema, inspect, search | neon-postgres |
| Existing PostgREST / Supabase database client | Data API (dataApi in neon.ts) |
| Generic REST endpoints | Function or existing handler, not Data API |
Use neon-auth to choose identity and to implement Managed Better Auth; the Auth guide points there. Keep existing Better Auth, Clerk, and Supabase Auth unless the user asked to migrate login. Auth cannot be enabled on a project with IP Allow or Private Networking.
Neon has no built-in key-value store or message queue. For a cache, rate limiting, or background jobs, pair it with Upstash Redis and QStash, and keep any Redis or queue the app already uses.
Neon Documentation
The Neon documentation is the source of truth for all Neon-related information. Always verify claims against the official docs before responding. Neon features and APIs evolve, so prefer fetching current docs over relying on training data.
Finding the Right Page
Look the page up before you fetch it — don't guess URLs! The docs index lists every available page with its URL and a short description:
https://neon.com/docs/llms.txt
Fetching Docs as Markdown
Any Neon doc page can be fetched as markdown in two ways:
- Append
.mdto the URL (simplest): https://neon.com/docs/introduction/branching.md - Request
text/markdownon the standard URL:curl -H "Accept: text/markdown" https://neon.com/docs/introduction/branching
Both return the same markdown content. Use whichever method your tools support.
Choosing the Right Skill
Neon provides a set of agent skills in addition to the official documentation. When a task matches one of the rows below, work from that skill rather than from this overview. You may have some of these skills already installed, or you may need to install them.
The skills below live in the neondatabase/agent-skills repo:
| Skill | Use it for |
|---|---|
neon-postgres |
Working with databases, including connections, schemas, queries, search, branching workflows, egress optimization, Free plan limits, autoscaling, performance, and scaling decisions. |
neon-auth |
Identity routing and Managed Better Auth setup (login, users, sessions, trusted domains). |
neon-object-storage |
Storing and serving files (uploads, images, blobs), including branching them with the database. |
neon-functions |
Deploying long-running or streaming serverless functions — APIs, agents, MCP servers, SSE/WebSocket servers, and Function Triggers (cron and object-storage). |
neon-ai-gateway |
Calling an LLM or routing across model providers with one credential, including discovering the branch's servable models at runtime via the OpenAI-compatible /v1/models endpoint. |
neon-realtime |
Realtime makes any SQL query live, for realtime, reactive apps and agents: enabling Realtime, sealing queries, React and TanStack DB bindings, SSR, and optimistic mutations. |
There is no neon-data-api skill. Configure dataApi in neon.ts only for PostgREST / Supabase database-client compatibility or a migration that already depends on it.
For guidance on agent platforms that provision and operate Lakebase Postgres on Neon at scale, use neon-postgres-agent-platforms, which lives in a separate repo: neondatabase/neon-for-agent-platforms.
Installing and Updating Skills
Install a missing skill with neon skills -s <skill-name>. For every new session, run neon skills status and update outdated skills with neon skills update -y. Before you install or update skills, read Installing the Right Skill.
Getting Started with Neon
Prefer the CLI over the MCP server unless the user instructs otherwise, the CLI is unavailable or blocked in your environment, or it is not authenticated, since it provides more capabilities, including deploying Neon Functions.
Check the CLI, then credentials
neon --version
If that fails, install first:
npm i -g neon # npm
bun add -g neon # bun
pnpm add -g neon # pnpm
For full CLI installation options, see https://neon.com/docs/cli/install.md
Then inspect credentials without printing secrets. NEON_API_KEY, or the active neon profile list -o json row (active: "*") with an account other than -, is an account. A DEFAULT row with account: "-" and file: "missing" is not.
- Credentials already available: reuse them. Do not launch a browser.
- A human needs to sign in: they run
neon login(neon authis an alias). An unattended agent must not launch browser authentication; with no credentials and nobody to finish a browser sign-in, it takes the Claimable Neon path below. - No account yet: follow Starting without a Neon account for the Claimable Neon path.
Set up agent tooling and link the project
When both agent tooling and project setup are needed, use authenticated neon init --agent <agent>. It writes neon.ts but doesn't deploy. Omit --mcp-auth unless the user asks for a method. If init installed the Neon plugin, don't also run neon mcp and neon skills for that agent. Otherwise: neon mcp --agent <agent> -y (always pass --agent; use --oauth for a project-level install so no key lands in git), neon skills, then neon link. If a supplied DATABASE_URL or AWS_* value must stay, pass --no-env-pull on link / checkout (init has no such flag).
Before you run neon init, neon mcp, neon skills, neon link, or neon bootstrap, read references/getting-started.md for the full commands, flags, and useful CLI commands.
Starting without a Neon account
If the Getting Started account check found credentials, use them. If those credentials fail to authenticate, stop and ask the user to sign in (neon auth). Do not create a Claimable project as a substitute for a failed existing account.
If the check found no credentials and nobody can finish a browser sign-in (an unattended run, or a command waits on Awaiting authentication in web browser), stop waiting and create the database with npx neon@latest claim create. It needs no Neon account, and the user claims the project later from the claim link; the next paragraph and its reference cover the flow. Use a Neon API key instead only when the user says they already have one; they set it as NEON_API_KEY in the session environment rather than pasting it into chat.
If there is no Neon account yet, read and follow references/claimable-neon.md before creating anything. It has the create flow, the REST fallback when neon claim is missing, expiry times, which services need a claim first (requires_claim), and how to add Auth or the Data API. Do not run neon init --agent or neon auth on this path; those need a human Neon account. Report project_expires_at and any denied capabilities instead of retrying.
Requests for neon.new, Claimable Postgres, claimable.neon.tech, instant Postgres, or a no-signup database are the same path.
Neon Infrastructure as Code
neon.ts is Neon's branch config and infrastructure-as-code file: declare which Neon services your project's branches should have, get type-safe env vars, and program branch settings — all in TypeScript. It's the config layer for your Neon services, and it composes with the branch-first loop below. Add it with @neon/config:
npm i @neon/config
Every project ships with Lakebase Postgres; neon.ts also declares auth, functions, buckets, aiGateway, and Realtime under preview. The Data API (dataApi) is a compatibility toggle, not part of a default backend. Don't replace an existing neon.ts wholesale with an example. Like Terraform: neon status shows the live config, neon config plan is a dry run, and neon deploy --env <file> applies neon.ts and then pulls the branch's env into your local env file.
Pass --env <file> every time Function env reads process.env. <file> is the file env pull writes; add Function secrets to it yourself. Declare each secret as { value: process.env.X, required: true }. Never coerce a missing value to an empty string: that uploads "" and deletes the live key.
Before you write or change neon.ts, read references/neon-ts.md for full examples, all Function env rules, the branch closure (TTL, compute size), and neon.ts type errors. For example, dataApi needs Auth or an external JWKS; don't enable Auth only to silence that error.
Function Triggers
A Function Trigger POSTs to a Neon Function on a cron (type: "schedule") or when an object is created in a bucket (type: "storage_object_created"). Same regions as Functions. Prefer a triggers map in neon.ts (the record key is the trigger name) and neon deploy. CLI, MCP, REST, inherited-trigger behavior, and parsers: references/function-triggers.md. Handler payload and Hono example: the neon-functions skill, references/function-triggers.md.
Type-safe env vars with parseEnv
@neon/env's parseEnv returns a typed env object from your neon.ts config. Require a subset of keys when an app does not need every implied variable: references/parse-env.md.
Branch-First Dev Flow
Neon branches enable a branch-first development flow, which we recommend when using Neon services. This and neon.ts above are the two halves of the recommended setup — neon.ts declares what every branch should have, and the branch-first loop is how you move between those branches day to day. Each works on its own, and they compose.
Create a Neon branch any time you would create a git branch. Use the following commands if you have CLI access:
neon checkout <branch-name>— Pins an existing branch by updating only the branch pointer in.neon. Pass--createto create a missing name (neon checkout dev --create). Run without a name for an interactive picker. It does not touch code or local Postgres.neon env pull— Fetches the current branch's Neon environment variables into your local env file (.envif it exists, otherwise.env.local).linkandcheckoutrun this for you by default, so you rarely call it directly.neon diff— Shows the schema diff between the child branch and its parent. Run this to see what changes have been made to the schema since the last branch was created and before you commit your changes.
neon link # once; also pulls the linked branch's env
neon checkout dev-add-search --create # per feature; also pulls the branch's env
Because link and checkout pull env by default, the branch's DATABASE_URL lands in your local env file automatically — build against it, then checkout the next branch and repeat. As the agent, drive this loop yourself: run checkout between tasks.
Checkout, neon.ts, and local env files
Checking out an existing branch never reconciles it with neon.ts. Apply changes with neon deploy --env <file>, and add --update-existing only after reviewing them. When neon.ts is present, neon checkout <name> --create --env <file> applies its policy to the new branch. To keep secrets off disk, pass --no-env-pull to link / checkout and inject env at runtime (neon-env run -- <cmd>). Before you create a branch with neon.ts present, or skip local env files, read references/branch-first.md.
Observability
Neon exposes branch-scoped logs for Functions and Object Storage today (aws-us-east-2, aws-us-east-1, aws-eu-central-1, and aws-ap-southeast-1). Query the branch that hosts the deployed function or bucket, not the checkout used for development.
neon logs query --since 1h
neon logs query --branch production --source function --minimum-severity error --since 6h
CLI flags, LogQL, MCP fallback, Loki HTTP, Grafana URLs, and @neon/sdk pagination: references/logs-loki.md.
Manage Neon Resources
Use @neon/sdk to manage projects, branches, and snapshots from TypeScript. New code should prefer it over @neondatabase/api-client.
Neon for (Agentic) Platforms
Enroll in the Neon Agent Program only when the work is a fleet of user databases (app-generating agents and platforms). A single-app backend skips this. Instant provision, snapshots, scale-to-zero compute (storage still billed), Auth, and Data API compatibility details: that page.
When You Run Into Issues
Report issues that Neon can fix upstream, such as incorrect guidance, broken templates, missing instructions, or defects in Neon tooling and APIs. Do not report errors caused only by the user's code, environment, permissions, or configuration unless Neon guidance or these agent skills caused the issue or failed to explain it.
Diagnose the issue and fully help the user first. Feedback must not delay or replace helping the user. After the task is complete, draft one report with the cause and workaround when known, show it to the user, and ask whether to send it to Neon. Send it only if they say yes.
After a yes, run neon feedback --help. If it succeeds, send the report with:
neon feedback --message "Describe what failed, including the command and sanitized error message."
Otherwise use the Neon MCP send_feedback tool when it is present. If neither is available, skip feedback. Do not install, upgrade, authenticate, or configure tooling only to send feedback. If submission fails, do not retry.
Never send secrets or sensitive data. Remove credentials, tokens, API keys, passwords, personal or customer data, and confidential project details from the report. Send only the issue report described above; do not collect or infer analytics.
