typebase-io-cli deploy
Deploy your Typebase server to the cloud with a single command.
Last updated on
The npx typebase-io-cli deploy command builds your server, pushes your database schema, and deploys everything to the cloud. Typebase supports three deployment providers:
- Vercel: serverless functions
- Cloudflare Workers: edge computing
- Deno Deploy: edge runtime
Quick start
Deploy to your dev environment:
npx typebase-io-cli deploy devDeploy to production:
npx typebase-io-cli deploy prodThe first time you run this, the CLI will ask you to:
- Select a deployment provider (Vercel, Cloudflare, or Deno)
- Authenticate with the provider
- Select or create a project on the provider
- Select or create a database on Neon (if your project has a database schema)
After the first deploy, the CLI remembers your choices in typebase.json, so future deploys are a single command.
What happens during deploy
When you run npx typebase-io-cli deploy, the CLI performs these steps automatically:
- Validates your TypeScript: Checks for type errors in your
typebase/directory. - Generates server files: Builds the server code from your actions, schema, and auth config.
- Transpiles to JavaScript: Converts TypeScript to JavaScript for deployment.
- Pushes your database schema: Syncs your Drizzle schema to your Neon database (if applicable).
- Deploys the server: Uploads the built server to your chosen provider.
- Sets environment variables: Configures
DATABASE_URLandBETTER_AUTH_SECRETon your provider. The key on the provider is alwaysDATABASE_URL, regardless of target; each environment (dev,prod) holds its own value. - Saves the URL and environment variables: Writes the deployment URL to your project-root
.env(TYPEBASE_APP_URLforprod,TYPEBASE_APP_URL_DEVfordev), along with the connection string (DATABASE_URLforprod,DATABASE_URL_DEVfordev).
Schema changes are applied (step 4) before the new server code is live (step 5). This is normal for most deployment workflows, but it means the
previous version of your server briefly runs against the new schema. For destructive changes in prod (dropped columns, renamed tables), design
your schema migrations so the old code keeps working, typically by rolling out additive changes first, then removing the old fields in a later
deploy.
Options
| Argument | Description |
|---|---|
target (required) | The environment to deploy to. Must be dev or prod. |
| Flag | Description |
|---|---|
--provider <provider> | Deployment provider: vercel, cloudflare, or deno |
Dev vs Prod environments
Typebase supports two separate environments:
| Environment | Use case |
|---|---|
dev | Development and testing. Uses a separate database branch. |
prod | Production. Uses the main database. |
Each environment gets its own:
- Deployment URL
- Database (or database branch)
- Environment variables
Deploy to dev:
npx typebase-io-cli deploy devDeploy to production:
npx typebase-io-cli deploy prodProvider setup
Vercel
When you deploy to Vercel for the first time:
- The CLI asks you to log in to Vercel (opens a browser).
- You select an existing Vercel project or create a new one.
- Your server is deployed as a Vercel Serverless Function using Hono as the HTTP adapter.
The deployment URL looks like: https://your-project.vercel.app
Cloudflare Workers
When you deploy to Cloudflare for the first time:
- The CLI asks you to log in to Cloudflare (opens a browser).
- You select or create a Cloudflare Worker.
- Your server is deployed as a Cloudflare Worker.
The deployment URL looks like: https://your-worker.your-subdomain.workers.dev
Cloudflare Workers use the Fetch API natively, so environment variables are handled through Cloudflare's secrets system rather than process.env.
Deno Deploy
When you deploy to Deno Deploy for the first time:
- The CLI asks you to log in to Deno Deploy.
- You select or create a Deno Deploy project.
- Your server is deployed as a Deno Deploy application.
The deployment URL looks like: https://your-project.your-organization.deno.net
Database provisioning
If your project has a db/schema.ts, the CLI will set up a Neon PostgreSQL database for you:
- First deploy: The CLI asks you to authenticate with Neon, then creates (or selects) a project.
- Schema push: Your Drizzle schema is pushed to the database.
- Environment variable: The connection string is set on your deployment provider under the key
DATABASE_URL, and mirrored into your project-root.envasDATABASE_URLfor prod orDATABASE_URL_DEV.
Dev and prod deployments use separate Neon branches, so your development data doesn't affect production.
Specifying the provider
You can skip the interactive prompt by passing the --provider flag:
npx typebase-io-cli deploy dev --provider vercelnpx typebase-io-cli deploy dev --provider cloudflarenpx typebase-io-cli deploy dev --provider denoOr set the provider in typebase.json so it's always used:
{
"serverProvider": "vercel"
}After deploying
After a successful deploy, the CLI prints the deployment URL:
Deployment URL: https://your-project.vercel.appThis URL is also saved to your .env file. The key depends on the target (TYPEBASE_APP_URL for prod, TYPEBASE_APP_URL_DEV for dev) so both can coexist:
TYPEBASE_APP_URL=https://your-project.vercel.app
TYPEBASE_APP_URL_DEV=https://your-project-dev.vercel.appUse this URL when setting up your client.
Managing environment variables
Use the npx typebase-io-cli env command to manage environment variables on your deployment provider.
Add a variable:
npx typebase-io-cli env dev add MY_KEY my-valueGet a variable:
npx typebase-io-cli env dev get MY_KEYSee the env command for more details.