Examples
Each example is a complete, deployable app whose entire data layer is
createEnv() — no URLs, no secrets. They’re deliberately small: one Flect
capability each, so you can see exactly how the code looks.
Notes — a database
Section titled “Notes — a database”The smallest env.db example: a public notes app. The whole data layer is three
lines.
const env = createEnv()const db = await env.db('DB') // an official @libsql/clientawait db.execute('SELECT ...')flect.toml needs one binding:
scope = "examples/notes/prod"
[[databases]]binding = "DB"name = "notes-db"- Live: https://flect-example-notes-6b6e4f.up.flect.run
- Source:
projects/flect-example-notesin the platform repo
Counter — a KV store
Section titled “Counter — a KV store”The smallest env.kv example: a shared counter. Atomic INCR/DECR, no
read-modify-write.
const env = createEnv()const kv = await env.kv('KV') // an official ioredis clientawait kv.incr('counter')scope = "examples/counter/prod"
[[kv]]binding = "KV"name = "counter-kv"- Live: https://flect-example-counter-5cdcd0.up.flect.run
- Source:
projects/flect-example-counterin the platform repo
The shape of every example
Section titled “The shape of every example”flect init # scaffold flect.tomlflect proj create --org <org> --ws <ws> --name app --slug app # create the scopeflect use <org>/<ws>/app # set the deploy target (the active context)docker build --platform linux/amd64 -t ghcr.io/you/app:0.1.0 . && docker push ghcr.io/you/app:0.1.0flect deploy # provisions the resource, binds, deploys to the active contextDeploy injects only FLECT_TOKEN + FLECT_BROKER_URL; the SDK resolves each
binding at runtime. For the low-level SDK snippets (db / kv / store / together),
see the examples/ folder in the platform repo.