Building

Database

Native Postgres on every project. You can import that data into Supabase and use Supabase as the database if you want.

Updated 5 Nov 2026

SpinBuild natively supports Postgres. Every project gets its own private Postgres database with its own role and password. It is created the first time the preview starts, or as soon as you choose Initialize database. No shared tables, and no way for one project to read another's data.

Anyone can import that data into Supabase and start using Supabase as the database if they want. Open Settings → Database, choose Supabase, then Continue with Supabase. The current tables, functions, and rows are copied over. After that, the app uses the Supabase database. You can switch back to native Postgres the same way. Full steps: Supabase.

What you get

  • A dedicated database on a Postgres 16 cluster reserved for project databases (separate from SpinBuild's own).
  • A role that can only access that database. It cannot connect to any other database and has no administrator rights: it cannot create databases or roles.
  • DATABASE_URL in your .env, pointing at it. The same database is used by the preview and by deployments, so data you enter while building is there in production.

Initialize database

Some projects start without a .env. For example, an app whose API lives in a separate server file, or one an AI assistant built over MCP. Initialize database connects it in one step:

  1. Creates the project's database, if it does not have one yet.
  2. Writes DATABASE_URL into .env. Your other variables and comments stay as they are.
  3. Creates no tables. Ask in the chat for what the app should save, and SpinBuild adds only the tables it needs, as migrations.

Find it in two places. Only the project owner sees it:

  • Builder → Files, when the project has .env.example but no .env.
  • Project settings → Database, while .env has no DATABASE_URL.

If .env already has a DATABASE_URL, nothing changes. If that value points at a database you set up elsewhere, SpinBuild asks you to confirm before replacing it. If the preview is running, restart it so the app picks up the new value.

AI assistants connected over MCP do the same with the initialize_my_project_database tool. The connection string is written into .env and is never shown to them.

The template's wiring

The starter project already talks to the database:

  • lib/db.ts — a pg connection pool built from DATABASE_URL, with a query<T>(text, params) helper.
  • lib/items.ts — creates an items table on first use and exposes listItems / addItem.
  • app/api/items/route.ts — a route handler the home page's form posts to.

Ask the model for tables and it will follow the same pattern: SQL through the pool, tables created if missing, server-side code only.

Working with schema

The template uses plain SQL rather than an ORM, which keeps generated code readable and reviewable. Typical prompts:

Add a calls table (customer_id → customers, notes, called_at) and a function to list calls for a customer.

We're storing money as floats — change amounts to integer cents everywhere.

Developers should read schema changes before accepting them. People who don't write code should check the preview, and use the version menu if the schema is wrong. See Reviewing changes. Adding an ORM (Prisma, Drizzle) is possible — ask for it — but it adds a migration step to every schema change.

If your project keeps SQL files in a migrations/ folder, Run migrations under Project settings → Database applies the pending ones. No preview is needed.

Looking inside

Project settings → Database lets you browse tables, sort, filter and export rows, view the schema, and run SQL against this project's active database only.

Use Supabase if you want

Native support is Postgres. If you want Supabase instead, import the data:

On Settings → Database, choose Supabase, then Continue with Supabase. Sign in to your account. SpinBuild copies the current public tables, functions, and rows onto a database on that account. From then on the app uses Supabase as the database. You do not paste a connection string. Usage is billed to your Supabase account.

Switching back to PostgreSQL imports the data the other way, onto native Postgres. Full steps: Supabase.

The connection string in .env is reachable only from inside SpinBuild's network. Where it is enabled, Connect a tool on the same page shows credentials for pgAdmin, psql or another Postgres client. They reach this project's database only.

Backups and lifetime

Project databases live as long as the project. Deleting a project drops its database. SpinBuild's nightly infrastructure backups cover project databases, but they're a disaster-recovery measure, not a point-in-time restore you can trigger — export anything you can't lose.

Limits

There are no per-row or per-table quotas. Storage is subject to fair use on all plans; if you're building something data-heavy, talk to us.