MainSDK
Search⌘K
Integrations

Neon

Use Neon for MainSDK data and backups - serverless Postgres per region, main.yaml, point-in-time restore, restore drills on branches and swapping.

2 interfaces2 driversWritten guide
Updated 2026-10-28

Neon is serverless Postgres, and a driver behind db and backup. Your records live in a Neon project per region, and Neon's point-in-time restore and branches give backup a fast way to run restore drills. Pick Neon for a Next.js app on Vercel, or whenever you want managed Postgres without running servers.

Interfaces it serves

Pick Neon in main.yaml for any of these. Your calls stay the same, and you can swap later.

Before you start

  1. Create a Neon project for each region your users are in, and check that Neon offers a region for each store you need.
  2. Copy each project's connection string and store it in your secrets manager.
  3. Review the project's history retention: it sets how far back point-in-time restore can go.

Configure

main.yaml
db:
  driver: neon
  regions:
    us: secret:DB_US        # suggested name; Neon connection string, US
    eu: secret:DB_EU        # suggested name; Neon connection string, EU
    in: secret:DB_IN        # suggested name; Neon connection string, India
backup:
  rpo: 15m
  rto: 1h
  keep: 35d
  drill: { every: 30d, to: scratch }

Point-in-time recovery comes from the Neon db driver's capability profile; there is no separate backup driver to set.

Use it

app/api/orders/route.ts
import { auth, db } from "mainsdk";

export async function GET(req: Request) {
  const session = await auth.require(req);
  return Response.json(await db.orders.for(session.user).list({ limit: 20 }));
}
scripts/drill.ts
import { runDrill } from "mainsdk/backup";

const result = await runDrill({ driver, declared, app: "my-app", at: new Date(), to: "scratch" });   // restores into scratch, never production

mainsdk drill restore --to scratch runs the same drill from the command line and signs the evidence.

Local development and testing

Use SQLite or a Neon development branch locally. createTestApp() from @mainsdk/testing runs db on its in-memory fake, and chaos.on("db", { outage: true }) simulates an outage. Run mainsdk drill restore in CI to test restores against Neon itself.

What MainSDK adds on top

  • Owner scope, region routing, field labels and idempotent writes, as on every db driver.
  • mainsdk check reads Neon's restore window and fails with the gap when it cannot meet your RPO.
  • Restore drills into a Neon branch, timed against your RTO and signed as evidence.

See Data and records and Backups and restore drills.

Limits and notes

  • The neon driver comes with the db spec (phase 1); neon-pitr comes with the backup-restore-evidence spec (phase 3, milestone 1.2).
  • MainSDK never runs or stores backups; Neon does.

Swap to or from it

main.yaml
db:
  driver: neon   # was postgres

FAQ

Is Neon just Postgres? Yes. Your Postgres schema and Prisma or Drizzle migrations work unchanged.

Can a drill touch my production branch? No. Drills restore only into a new branch or scratch database.

Next

Was this page helpful?

↑↓ moveEnter openEsc close

Not decided yet