Getting started
On this page
Create an accountScaffold your first functionWrite your functionDevelop locallyDeployAttach bindingsView in the dashboardDeploy via APINext stepsCreate an account
Sign up at app.fold.run/console/signup or via the CLI:
npm install -g @fold-run/cli
fold loginfold login opens a browser to authenticate and saves a token locally. Requires Node.js 18+.
Scaffold your first function
fold init my-function
cd my-functionThis creates:
my-function/
├── function.ts # Your function code
├── fold.json # Project config (name, entrypoint, bindings)
├── package.json # devDependency: @fold-run/runtime
└── tsconfig.json # TypeScript config@fold-run/runtime is installed automatically and provides the typed FoldContext API.
Write your function
function.ts starts with a working example:
import { defineHandler, type FoldContext } from '@fold-run/runtime';
export default defineHandler(async (fold: FoldContext) => {
const name = new URL(fold.request.url).searchParams.get('name') ?? 'world';
return fold.json({ message: `Hello, ${name}!` });
});fold gives you typed access to your request, bindings, AI, and env vars — no raw env object needed.
Develop locally
fold devStarts a local server at http://localhost:8000 with auto-reload on save. Platform bindings (fold.kv, fold.db, etc.) are in-memory stubs locally.
Pass env vars for local testing:
# Auto-loaded from .env in cwd
echo "API_KEY=test-key" >> .env
# Or inline
fold dev -e API_KEY=test-keyDeploy
fold deployDeploys using fold.json. Your function goes live at https://<tenant>.fold.run/<name> (default workspace) or https://<workspace>.<tenant>.fold.run/<name> for non-default workspaces.
curl https://my-tenant.fold.run/my-function?name=Fold
# → {"message":"Hello, Fold!"}Attach bindings
Add platform resources via the dashboard (Functions → Bindings) or fold.json:
| Binding | fold accessor |
Use for |
|---|---|---|
| KV | fold.kv |
Key-value storage |
| DB | fold.db |
SQL database |
| Storage | fold.storage |
Object storage |
| AI | fold.ai |
Model inference |
| Queue | fold.queue |
Async messaging |
Env vars and secrets are available on fold.env:
fold secrets set API_KEY=sk-...const key = fold.env.API_KEY;View in the dashboard
Visit app.fold.run/console:
- Functions — deployed functions, versions, URLs
- Activations — execution logs with duration, status, and console output
- Logs — real-time log stream and searchable history
- Secrets — encrypted environment variables
- Bindings — attach KV, DB, Storage, AI, Queue to functions
- Workspaces — isolated resource boundaries (staging, production, etc.)
- Teams — invite collaborators and manage roles
- Billing — plan, usage, and upgrade
Deploy via API
You can also deploy directly without the CLI:
curl -X POST https://api.fold.run/deploy \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"tenant_id": "my-tenant",
"name": "my-function",
"code": "export default { fetch(req) { return new Response(\"hello\"); } }"
}'Next steps
- Deploy and rollback — full deploy API, multi-file deploys, and rollback
- Streaming — SSE and streaming AI responses
- Pipelines — chain functions and MCP tools
- Guardrails — content filtering and safety policies
- Workspaces — separate environments with isolated resources
- Domains — custom domains for your functions
- A2A protocol — agent-to-agent communication