DocsGet started
Quickstart
Create a Postgres database, run a query, and point your app at it.
You need Node.js 20 or newer for the bata CLI. Everything below can also be
done in the console at app.batadata.com.
1. Sign up and add a card
Create an account at app.batadata.com/register. Your account starts with a team on the Free plan.
The Free plan needs a card on file before any database can run. Add one on the console's Billing page. Nothing is charged while you stay inside the free allowance: by default a Free team stops at its allowance instead of billing you. See Pricing and billing.
2. Install the CLI and log in
npm install -g @batadata/cli
bata loginbata login prints a code and opens the console. Type the code there and
approve it. The CLI saves its own key on this machine, so you log in once.
bata whoamibata whoami shows the team you are working in. Projects are billed to that team.
3. Create a project
bata create my-appThis creates a project with one branch, main, and a serverless compute. It
waits for the compute to start, then prints the project id and both
connection strings.
The new project becomes the default for later commands if you have no default
yet. To tie a directory to it, run bata link <project-id> inside it. That
writes .batadata/project.json, which holds no secret and is safe to commit.
4. Run a query
bata db query "select version()"Or open an interactive session (needs psql installed):
bata db connectAn idle database scales to zero. The first query after a quiet spell wakes it,
and bata db query waits for that.
5. Connect your app
bata db url --jsonYou get two connection strings:
- Pooled goes in your app as
DATABASE_URL. Use it for app traffic and serverless functions. - Direct goes wherever you need a full session: migrations,
pg_dump,LISTEN/NOTIFY. Store it asDIRECT_URL.
import pg from 'pg';
const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL });
const { rows } = await pool.query('select now()');Both strings carry the password. Keep them in environment variables, never in code. Connecting covers the difference in detail, plus Prisma and edge runtimes.
6. Give previews their own branch
bata db branch create preview
bata db url --branch preview --jsonA branch is a copy-on-write copy of its parent's data at the moment you create it, with its own compute and its own connection strings. Point preview deployments at a branch, not at production.
Next steps
- Connecting: pooled vs direct, Prisma, SQL over HTTP.
- Pricing and billing: rates, the free allowance, how usage is metered.
- Migrate from Neon: move an existing database with
bata import. - Agents quickstart: drive BataDB from an agent over MCP or the CLI.
- CLI reference: every
batacommand.