Skip to content

Frontend Deployment

Deploy your frontend directly from Butterbase. Build your app locally, zip the output, upload it, and deploy to a live URL powered by Cloudflare Pages.

Frontend deployments are served globally and aren’t tied to a single region — your static assets reach users fast no matter where your app’s backend lives.

  1. Call create_frontend_deployment to get a deployment ID and upload URL
  2. Upload your built frontend as a zip file
  3. Call start_frontend_deployment to trigger the deployment
  4. Your site goes live at a .pages.dev URL
FrameworkValueNotes
React (Vite)react-vitedist/ folder from npm run build
Next.js (static)nextjs-staticout/ folder from next build && next export
Static HTMLstaticAny plain HTML/CSS/JS files
OtherotherAny framework that produces static output

Step 1: Create deployment

create_frontend_deployment({ app_id: "app_abc123", framework: "react-vite" })

Step 2: Upload your zip

Terminal window
curl -X PUT "{uploadUrl}" \
-H "Content-Type: application/zip" \
--data-binary @frontend.zip

Step 3: Start deployment

start_frontend_deployment({ app_id: "app_abc123", deployment_id: "uuid-1234" })
StatusMeaning
WAITINGCreated, awaiting zip upload
UPLOADINGFiles are being processed
BUILDINGDeployment is being built
READYSucceeded — URL is assigned
ERRORFailed — check the error message
CANCELEDDeployment was canceled
Terminal window
npm install archiver --save-dev
zip-dist.js
const fs = require('fs');
const path = require('path');
const archiver = require('archiver');
const output = fs.createWriteStream(path.join(__dirname, 'frontend.zip'));
const archive = archiver('zip', { zlib: { level: 9 } });
output.on('close', () => {
console.log(`frontend.zip created (${archive.pointer()} bytes)`);
});
archive.on('error', (err) => { throw err; });
archive.pipe(output);
archive.directory('dist/', false);
archive.finalize();
Terminal window
cd dist && zip -r ../frontend.zip .

Set environment variables for frontend builds:

PUT /v1/{app_id}/frontend/env
{
"VITE_API_URL": "https://api.butterbase.ai/v1/app_abc123",
"VITE_APP_NAME": "My App"
}

Framework-specific prefixes:

  • Vite: VITE_ (e.g., VITE_API_URL)
  • Next.js: NEXT_PUBLIC_ (e.g., NEXT_PUBLIC_API_URL)
  • Create React App: REACT_APP_ (e.g., REACT_APP_API_URL)

For single-page app frameworks, a _redirects file is automatically injected so all routes serve index.html. Client-side routing works out of the box. If your zip includes a custom _redirects, it is preserved.

  • Free plan: Deploying again automatically replaces your existing deployment.
  • Pro and above: Each deployment is kept independently. Delete old deployments manually.

Connect your own domain to your deployed frontend. Requires Pro plan or above.

  1. Add your domain via the dashboard, CLI, or API
  2. Add a CNAME record at your DNS provider pointing to butterbase.dev
    • Cloudflare DNS users: set the record to DNS-only (grey cloud). Proxied (orange cloud) CNAMEs between different Cloudflare accounts produce Error 1014.
  3. SSL is automatically provisioned — check status in the dashboard or via API
  4. Once active, your site is live at your custom domain
Terminal window
butterbase domains add app.example.com
butterbase domains status <domain-id>
POST /v1/{app_id}/custom-domains
{ "hostname": "app.example.com" }

For bare domains like example.com, your DNS provider must support CNAME flattening. Otherwise use www.example.com with a redirect from the apex.

LimitValue
Maximum deployment size100 MB (compressed)
Upload URL expiration15 minutes
Free plan1 active deployment per app
Pro planUnlimited deployments