Getting Started
Install Typebase and make your first server call.
Last updated on
Prerequisites
Node.js 20+
18 works, 20+ recommended. The latest LTS is ideal. It matches what the CLI, Neon, and the popular deploy targets are tested against.
A package manager
npm, pnpm, yarn, or bun. Anything that reads a package.json works. The CLI auto-detects which one your project uses.
Using an AI coding agent
Typebase ships an AI Skill: a single SKILL.md that teaches your agent (Claude Code, Cursor, and others) the whole mental model, file layout, CLI commands, and common pitfalls. With it installed, the agent can scaffold actions, edit the schema, wire up auth, and deploy without re-reading the docs each time.
Install it with the skills CLI from skills.sh:
npx skills add typebase-io/monorepoThen just tell your agent what to build. See the AI Skill page for manual installation and more detail. The rest of this guide is the manual path.
Install
Typebase is split into two packages. typebase-io is the core library. It provides the action builder for your server code and the client utilities for your frontend. typebase-io-cli is the CLI tool that handles code generation, schema pushes to your database, and deployment.
npm install typebase-ioThen install the CLI as a dev dependency, since you only need it during development:
npm install -D typebase-io-cliAdd a typebase script to your package.json:
{
"scripts": {
"typebase": "typebase-io-cli"
}
}This lets you run CLI commands through your package manager, e.g. npm run typebase init. The script is optional: because the CLI is installed as a local dev dependency, npx typebase-io-cli <command> works without it (that's the form used throughout these docs). Either way, any teammate who clones the repo and runs npm install gets the same CLI version.
Using CommonJS?
Typebase ships two CLI binaries: typebase-io-cli (ESM) and typebase-io-cli-cjs (CommonJS). Use typebase-io-cli if your project has "type": "module" in package.json. This is the default for most modern setups (Next.js 14+, Vite, SvelteKit, Nuxt 3).
If your project still uses CommonJS (either you don't set "type" in package.json, or you set it to "commonjs" explicitly), use typebase-io-cli-cjs instead. The two binaries are functionally identical; the only difference is which module system they're built with, so they can interop cleanly with the rest of your project.
{
"scripts": {
"typebase": "typebase-io-cli-cjs"
}
}You only need to make this choice once. Everything inside your typebase/ directory (actions, schema, auth) is always written in TypeScript and is compiled to whatever your deployment target needs. Your project's module system doesn't change anything there.
Initialize
Scaffold the typebase/ directory:
npx typebase-io-cli initThis creates your backend directory with example files. If you want the examples to include authentication setup, pass --with-auth. If you'd rather start from scratch without any examples, pass --skip-example.
If your project has a src/ directory, Typebase will create the files inside src/typebase/ instead. You can customize this path in
typebase.json.
Your first action
The init command already created example actions. Open typebase/actions/queries/todos.ts to see what one looks like:
import { ServerError } from 'typebase-io/server';
import { z } from 'zod';
import { action } from '../../_generated/server.ts';
export const getOne = action
.input(
z.object({
id: z.number(),
})
)
.output(
z.object({
id: z.number(),
value: z.string(),
completed: z.boolean(),
})
)
.handler(async ({ db, input }) => {
const todo = await db.query.todos.findFirst({
where: { id: input.id },
});
if (!todo) {
throw new ServerError('NOT_FOUND');
}
return {
id: todo.id,
value: todo.value,
completed: todo.completed,
};
});Each exported action with a .handler() becomes a callable endpoint on your client. Feel free to edit these files or add new ones. Run codegen whenever you create or delete a file inside actions/, or when you add or remove auth.ts, db/schema.ts, or db/relations.ts:
npx typebase-io-cli codegennpx typebase-io-cli deploy runs this for you as part of every deploy, so you only need to invoke codegen explicitly when you're iterating
without redeploying.
See Actions to learn everything about writing actions.
Deploy
Deploy your server to the cloud:
npx typebase-io-cli deploy devOn first run, the CLI will ask you to:
- Choose a deployment provider (Vercel, Cloudflare Workers, or Deno Deploy)
- Log in to that provider
- Set up a PostgreSQL database (via Neon)
After setup, running npx typebase-io-cli deploy dev is a single command. The CLI saves your server URL to .env as TYPEBASE_APP_URL_DEV (deploying prod uses TYPEBASE_APP_URL instead, so both can coexist).
See Deploy for the full deployment reference.
Call it from your frontend
Read the Client overview for a quick tour of what the client offers, or jump straight to your framework's integration guide for full setup: