Neon
Use Neon for MainSDK data and backups - serverless Postgres per region, main.yaml, point-in-time restore, restore drills on branches and swapping.
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.
dbBuilding for 0.3Driver neon Neon
db:
driver: neonSwap to another provider
backupBuilding for 1.2Driver neon-pitr Neon point-in-time recovery
backup:
driver: neon-pitrBefore you start
- Create a Neon project for each region your users are in, and check that Neon offers a region for each store you need.
- Copy each project's connection string and store it in your secrets manager.
- Review the project's history retention: it sets how far back point-in-time restore can go.
Configure
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
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 }));
}import { runDrill } from "mainsdk/backup";
const result = await runDrill({ driver, declared, app: "my-app", at: new Date(), to: "scratch" }); // restores into scratch, never productionmainsdk 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
dbdriver. mainsdk checkreads 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
neondriver comes with the db spec (phase 1);neon-pitrcomes with the backup-restore-evidence spec (phase 3, milestone 1.2). - MainSDK never runs or stores backups; Neon does.
Swap to or from it
db:
driver: neon # was postgresFAQ
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?