Quickstart
This walks you from a fresh login to a deployed app with a database and a cache.
Prerequisites
Section titled “Prerequisites”- Node.js 20+ and the Flect CLI
- Docker and a container registry (GitHub Container Registry, Docker Hub, …) to build and push your image
1. Install the CLI
Section titled “1. Install the CLI”npm install -g @getflect/cli2. Log in and point at the platform
Section titled “2. Log in and point at the platform”flect loginflect config set gatewayUrl https://flect.cloud # the hosted control plane # (self-hosted: your gateway origin)flect login opens your browser for SSO and stores an identity token in
~/.flect/config.json. gatewayUrl is the single origin the CLI talks to — the
identity plane and the broker both derive from it. Confirm everything is wired:
flect whoami # your identity + where you're pointedflect doctor # green-checks config, plane, broker, token, and scope3. Scopes — where things live
Section titled “3. Scopes — where things live”Flect organizes everything as a tree: Org → Workspace → Project →
Environment. Your login gives you an org; you create the rest with the noun
commands, then pick an active context with flect use — resource and deploy
commands target it.
flect org create --name Acme --slug acmeflect ws create --org acme --name Web --slug webflect proj create --org acme --ws web --name Site --slug siteflect ls # inspect the tree (active node marked)flect use acme/web/site # set the active contextflect ps prints the active context (scope, token, broker) at a glance.
4. Scaffold flect.toml
Section titled “4. Scaffold flect.toml”In your project directory:
flect initThis writes a starter flect.toml and adds flect.local.json / .flect/ to
.gitignore:
name = "myapp"runtime = "node"port = 3000scope = "myapp/main/prod" # reserved/ignored — deploy target comes from `flect use` (step 3)
[[databases]]binding = "DB"name = "myapp-db"
[[kv]]binding = "CACHE"name = "myapp-cache"scopeis reserved today; the deploy target is your active context (flect use, step 3).bindingis the name your code uses:env.db('DB').nameis the Flect resource it maps to.
See the flect.toml reference for every field.
5. Write your app
Section titled “5. Write your app”Your code only needs @getflect/sdk. It never sees a URL or a secret.
npm install @getflect/sdkimport { createEnv } from '@getflect/sdk'
const env = createEnv()
const db = await env.db('DB') // an official @libsql/clientconst cache = await env.kv('CACHE') // an official ioredis client
await db.execute('CREATE TABLE IF NOT EXISTS hits (n INTEGER)')await cache.set('ping', 'pong')Try it locally first — see Local development.
6. Deploy
Section titled “6. Deploy”Build and push your image, set it in flect.toml (or pass --image on the app
entry), then:
docker build -t ghcr.io/you/myapp:1.0.0 .docker push ghcr.io/you/myapp:1.0.0
flect deployflect deploy reads flect.toml, targets your active context (from flect use in step 3), provisions any missing resources, binds them to your
project, and deploys your container to the cluster behind Traefik with an
auto-issued TLS certificate.
scope: acme/web/site (active context)✓ provisioned database myapp-db-a1b2c3d4✓ provisioned kv myapp-cache-e5f6g7h8✓ deployed myapp https://myapp-3f9k2a.up.flect.run runningAt deploy time Flect injects exactly two env vars into your container —
FLECT_TOKEN and FLECT_BROKER_URL. createEnv() uses them to resolve each
binding to a scoped, short-lived connection at runtime.
Next steps
Section titled “Next steps”- Local development —
flect dev+createEnv()offline. - Examples — small single-purpose apps (a database, a KV store).
- CLI reference · SDK reference · flect.toml