Ready to deploy your app? Here’s how to go from local development to production.
When moving from development to production, change your region from "dev" to "na1":
// ❌ Development
const backend = new Backend('any-key', 'dev');
// ✅ Production (managed hosting)
const backend = new Backend('your-real-public-key', 'na1');
// ✅ Production (self-hosted)
const backend = new Backend('your-real-public-key', 'https://your-domain.com');
That’s it! The StaticBackend client library handles everything else.
Before deploying, make sure you:
"dev" with "na1" (or your self-hosted URL)Environment variables (recommended):
// Use environment variables in your build
const backend = new Backend(
process.env.STATICBACKEND_PUBLIC_KEY,
'na1'
);
Add to your .env file (never commit this!):
STATICBACKEND_PUBLIC_KEY=your-real-public-key-here
Different platforms handle environment variables differently:
Vercel:
# Add to Vercel project settings
STATICBACKEND_PUBLIC_KEY=your-key
Netlify:
# Add to Netlify site settings
STATICBACKEND_PUBLIC_KEY=your-key
GitHub Actions:
env:
STATICBACKEND_PUBLIC_KEY: ${{ secrets.STATICBACKEND_PUBLIC_KEY }}
Your frontend can be deployed anywhere. Here are popular options:
# Install Vercel CLI
npm i -g vercel
# Deploy
vercel
Add environment variables in Vercel dashboard under Settings → Environment Variables.
# Install Netlify CLI
npm i -g netlify-cli
# Deploy
netlify deploy --prod
Add environment variables in Netlify dashboard under Site Settings → Environment Variables.
Perfect for static sites:
npm run build
# Push the build folder to gh-pages branch
Note: Environment variables must be set at build time for static sites.
Upload your built files via FTP, SFTP, or use a deploy script:
npm run build
scp -r dist/ user@yourserver.com:/var/www/html/
Create a Dockerfile for your frontend:
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
ARG STATICBACKEND_PUBLIC_KEY
ENV STATICBACKEND_PUBLIC_KEY=$STATICBACKEND_PUBLIC_KEY
RUN npm run build
CMD ["npm", "start"]
Build and deploy:
docker build --build-arg STATICBACKEND_PUBLIC_KEY=your-key -t myapp .
docker run -p 3000:3000 myapp
The CLI provides a proxy to test your local app against production:
backend proxy
This routes localhost:8099 requests to StaticBackend’s production API.
Use this to:
Important: Stop your local dev server first (backend server) before starting the proxy.
For larger projects, consider a staging deployment:
Problem: Using development settings in production
Solution: Make sure you changed "dev" to "na1" and are using your real public key.
Problem: Variables not loaded at build time
Solution: Check your platform’s documentation. Most static site generators need variables at build time, not runtime.
Problem: Frontend domain not configured
Solution: StaticBackend allows requests from any origin by default. Check your browser console for the actual error.
Problem: Using wrong region or keys
Solution: Verify you’re using production keys and the correct region ("na1").
Never hardcode keys in your source code:
// ❌ Don't do this
const backend = new Backend('pk_1234567890abcdef', 'na1');
// ✅ Do this
const backend = new Backend(process.env.STATICBACKEND_PUBLIC_KEY, 'na1');
Your root token is for server-side operations only:
Use your StaticBackend dashboard to:
Add error tracking to catch production issues:
const result = await backend.create(token, 'todos', data);
if (!result.ok) {
// Log to your error tracking service
console.error('Failed to create todo:', result.content);
// Show user-friendly error
alert('Something went wrong. Please try again.');
}
When updating your deployed app:
backend serverbackend proxyIf you’re self-hosting StaticBackend, see our self-hosting guide for deployment details.
Key differences:
"na1"Questions about deployment? Ask in our GitHub Discussions
© 2023 Focus Centric Inc. All rights reserved.