Building with Neon Postgres
Neon Postgres support is in beta. Some features may have known issues.
Prerequisites
- Cubby CLI installed and logged in (
cubby login) - Node.js 18 or later
- A Builder (19.99/mo) plan — Neon Postgres requires Builder or higher
Create Your App
Runcubby init and select the Next.js + Neon Postgres template:
nextjs-neon template and creates a project with:
cubby.yaml:
Understanding the Database
When you deploy withdatabase: { provider: neon }, Cubby provisions a Neon Postgres database automatically:
- One Neon project per user, with individual databases per app
DATABASE_URLandDIRECT_URLare injected into your app’s environment- Prisma uses the Neon serverless driver (
@prisma/adapter-neon) for WebSocket connections
Install and Develop
http://localhost:3000, with database settings shaped like the Cubby runtime.
Define Your Data Model
Editprisma/schema.prisma to add your models:
Deploy
When you’re ready, deploy to Cubby:- Verification: Pre-build checks, AI review, and PWA auto-fix
- Cloud Build: Your Docker image is built in Google Cloud Build
- Database provisioning: Neon Postgres database is created (or reused on redeploy)
- Schema sync:
prisma db pushruns automatically to apply your schema - Container start: Your app goes live with
DATABASE_URLinjected
Working with Your Database
Cubby provides database management commands viacubby db:
Export Your Data
Create a Branch
List Branches
Take a Snapshot
List Snapshots
Prisma Schema Changes
When you change your Prisma schema and redeploy:- Update
prisma/schema.prismawith your changes - Run
cubby deploy - Cubby runs
prisma db pushautomatically during deploy
prisma db push applies schema changes non-destructively. It creates new tables and columns but does not drop existing data. For destructive changes (removing columns, renaming tables), you’ll need to handle the migration manually.
Differences from SQLite
Choose SQLite when your app is simple, single-user, or you want to stay on the free tier. SQLite is fast, requires no external services, and works on all plans.
Choose Neon Postgres when you need concurrent writes from multiple users, complex queries with joins, or database features like branching and snapshots. Neon databases persist independently of your container, so data survives even if the container is replaced.
Related
- Building Database Apps - SQLite and Prisma basics
cubby db- Database CLI reference- Pricing and Billing - Plan requirements for Neon
cubby init- Create a new app