Local Development Server

Develop your app locally with the CLI development server. No account needed, no setup required—just start building.

Quick start

Make sure you’ve installed the CLI, then run:

backend server

Your local StaticBackend API is now running at http://localhost:8099

What you can do

With the local development server, you can:

The local server has the exact same API as production, so your code works the same everywhere.

Using with your app

Initialize StaticBackend in your code with the “dev” region:

import { Backend } from '@staticbackend/js';

// Use "dev" region for local development
const backend = new Backend('any-pub-key', 'dev');

// The library will automatically connect to localhost:8099

The public key can be any value when using the dev server—it’s not validated locally.

Data persistence

Default: In-Memory (Temporary)

By default, data is stored in memory and cleared when the server stops. Perfect for quick tests and experimentation.

backend server
# Data will be lost on restart

To keep your data across restarts, use the --persist-data flag:

backend server --persist-data

This uses SQLite to store data permanently on your local machine. Your development data persists until you manually delete it.

When to use persistent mode:

Custom port

The server runs on port 8099 by default. Change it if needed:

backend server -p 8088

Update your app to connect to the new port:

const backend = new Backend('any-pub-key', 'dev', 'http://localhost:8088');

Limitations

The in-memory database has minor limitations:

Solution: Use --persist-data mode for full feature parity with production.

Stop the server

Press Ctrl+C in the terminal where the server is running.

Switching to production

When you’re ready to deploy:

  1. Create a managed account or self-host
  2. Get your production API keys
  3. Change the region from "dev" to "na1" in your code:
// Development
const backend = new Backend('any-pub-key', 'dev');

// Production (managed hosting)
const backend = new Backend('your-real-public-key', 'na1');

That’s it! Your app now uses the production backend with zero code changes.

Common workflows

Test then deploy

# 1. Develop locally
backend server --persist-data

# 2. Test your app at http://localhost:3000 (or your dev server)

# 3. When ready, change region to 'na1' and deploy

Multiple projects

Each project can run its own dev server on different ports:

# Project 1
cd ~/projects/app1
backend server -p 8099

# Project 2 (different terminal)
cd ~/projects/app2
backend server -p 8088

Next steps


Need help? Join our GitHub Discussions

© 2023 Focus Centric Inc. All rights reserved.