Environment Variables
Most applications need environment variables — database URLs, API keys, feature flags, third-party credentials. Sp00ky provides a single env property on every app in sp00ky.yml that handles environment variables across local development and cloud deployment.
Additionally, Sp00ky auto-injects a set of SPKY_* variables into every app so your services can connect to infrastructure without manual configuration.
Auto-Injected Variables
Every app (backend and frontend) automatically receives these variables — no configuration needed:
| Variable | Description | Dev example | Cloud example |
|---|---|---|---|
SPKY_ENV | Current environment | dev | cloud |
SPKY_DB_URL | SurrealDB HTTP endpoint | http://localhost:8666 | http://10.100.1.10:8000 |
SPKY_DB_WS | SurrealDB WebSocket endpoint | ws://localhost:8666 | ws://10.100.1.10:8000 |
SPKY_DB_NS | SurrealDB namespace | From sp00ky.yml | From deployment config |
SPKY_DB_NAME | SurrealDB database name | From sp00ky.yml | From deployment config |
SPKY_DB_USER | SurrealDB username | From sp00ky.yml | root |
SPKY_DB_PASS | SurrealDB password | From sp00ky.yml | Auto-generated |
SPKY_SSP_ADDR | SSP endpoint | http://localhost:8667 | http://10.100.1.30:8667 |
SPKY_SCHEDULER_URL | Scheduler endpoint (cluster mode) | http://localhost:9667 | http://10.100.1.20:9667 |
Use SPKY_DB_URL for HTTP-based SDKs (JavaScript, Python) and SPKY_DB_WS for WebSocket-based SDKs (Rust SurrealDB client). Both always point to the same database — just different protocols.
Auto-injected variables can be overridden — if you set SPKY_DB_URL in your env config, your value takes precedence over the auto-injected one.
Custom Environment Variables
Beyond the auto-injected SPKY_* variables, you can provide your own using the env property. It accepts several forms.
From a File
A .env file with one KEY=VALUE per line. Comments (#) and blank lines are ignored.
The path is resolved relative to your sp00ky.yml.
Don’t commit .env files containing secrets to version control. Add them to .gitignore and use the encrypted vault for production secrets.
Inline
Define variables directly in the config:
Values can be strings, numbers, or booleans.
From the Vault
For production secrets, use the encrypted vault:
This loads all variables from the vault. To load only specific ones, pass a whitelist:
Vault variables must be set up first with spky cloud env init and spky cloud env set. See Cloud Environment Variables for the full setup guide.
Per-Environment
Use different sources for local development vs cloud deployment:
Each side accepts any form — a file path, inline map, "vault", a vault whitelist, or an array.
Layering Multiple Sources
Combine multiple sources in an array. Later entries override earlier ones by key:
Arrays also work inside per-environment splits:
Full Example
A realistic sp00ky.yml showing environment variables across a frontend and two backends. Note that SPKY_DB_* variables are auto-injected — you only need to configure app-specific secrets.
How Variables Are Injected
| Context | Behavior |
|---|---|
spky dev (npm, uv) | SPKY_* auto-injected + user vars set in the spawned process environment |
spky dev (docker) | SPKY_* auto-injected + user vars passed as -e KEY=VAL flags to docker run |
spky cloud deploy | SPKY_* auto-injected by the orchestrator + user vars from the deployment manifest |
"vault" in dev | The CLI fetches decrypted variables from the Sp00ky Cloud API (requires spky cloud login) |
"vault" in deploy | Variables are fetched server-side and included in the manifest |
User-provided variables always take precedence over auto-injected SPKY_* variables.
Validating Your Config
Run spky lint to check that all referenced env files exist before deploying: