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.

  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.
LimitValue
Maximum deployment size100 MB (compressed)
Upload URL expiration15 minutes
Free plan1 active deployment per app
Pro planUnlimited deployments