Develop your app locally with the CLI development server. No hosted account is required.
The local server is a full StaticBackend BaaS runtime running on your machine. By default it uses the in-memory database and cache providers from the core project, so it is fast to start and easy to reset.
Make sure you have installed the CLI, then start the local server:
backend server
The local StaticBackend API is now running at http://localhost:8099.
In another terminal, create a CLI config file for local development:
backend login --dev
This writes a .backend.yml file in the current directory with local development credentials:
pubKey: dev_memory_pk
region: dev
rootToken: safe-to-use-in-dev-root-token
email: admin@dev.com
password: devpw1234
authToken: generated-auth-token
Add .backend.yml to .gitignore if it is not already ignored.
With the local development server, you can:
The local server maps to the same StaticBackend API surface as hosted and self-hosted environments, so your application code can keep the same backend calls when you switch regions.
Initialize StaticBackend in your code with the dev region:
import { Backend } from '@staticbackend/js';
const backend = new Backend('dev_memory_pk', 'dev');
The dev region points client libraries to http://localhost:8099.
Use the built-in local admin user when you need an email and password:
admin@dev.com
devpw1234
Keep the server running in one terminal:
backend server
Use another terminal in the same project directory:
backend login --dev
backend db create tasks '{"name":"Write docs","done":false}'
backend db list tasks
backend users add user@example.com a-password
The CLI reads .backend.yml from the current directory by default. Use --config if your config file lives somewhere else:
backend --config ./path/to/.backend.yml db list tasks
By default, data is stored in memory and cleared when the server stops:
backend server
This is the fastest mode and is useful for quick tests, demos, and clean development runs.
To keep data across restarts, use --persist-data:
backend server --persist-data
This switches the local database provider to SQLite and writes to local.db in the directory where you started the server. The cache still uses the in-memory development provider.
Use persistent mode when:
Delete local.db when you want to reset persistent local data.
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('dev_memory_pk', 'dev', 'http://localhost:8088');
For local file uploads, prefer the default 8099 port. The current CLI server still builds local file URLs with http://localhost:8099.
Use --no-log to reduce request and response logging:
backend server --no-log
Press Ctrl+C in the terminal where the server is running.
When you are ready to deploy:
backend login to create a production .backend.ymldev to your hosted region or self-hosted URL// Development
const backend = new Backend('dev_memory_pk', 'dev');
// Managed hosting
const backend = new Backend('your-real-public-key', 'na1');
// Self-hosted
const backend = new Backend('your-real-public-key', 'https://api.yourdomain.com');
backend server
backend login --dev
Stop and restart the server to clear all data.
backend server --persist-data
backend login --dev
Delete local.db to reset data.
Each project can run its own dev server on a different port:
# Project 1
cd ~/projects/app1
backend server -p 8099
# Project 2
cd ~/projects/app2
backend server -p 8088
© 2023 Focus Centric Inc. All rights reserved.