---
title: Local World
description: Zero-config world bundled with Workflow for local development. No external services required.
docs_index: /llms.txt
lastUpdated: 2026-11-26
type: integration
summary: Set up the Local World for zero-configuration workflow development on your machine.
prerequisites:
  - /docs/deploying
related:
  - /worlds/postgres
  - /worlds/vercel
---

> For an index of all documentation, see [/llms.txt](/llms.txt).

The Local World is bundled with `workflow` and used automatically during local development. It requires no installation or configuration.

To explicitly use the Local World in any environment, set this environment variable:

```bash
WORKFLOW_TARGET_WORLD=local
```

## Observability

The Workflow CLI uses the Local World by default. Run these commands inside your workflow project to view your local development workflows:

```bash
# List recent workflow runs
npx workflow inspect runs

# Launch the web UI
npx workflow web
```

`npx workflow inspect run <run_id> --usage` shows where a run's events come from and how much it stores; see [Usage](/docs/observability/usage).

Learn more in the [Observability](/docs/observability) documentation.

## Testing & compatibility

## Configuration

The Local World requires no configuration, but you can customize its behavior through environment variables or programmatically through `createWorld()` (see [Programmatic configuration](#programmatic-configuration)).

**Common**

| Variable                                              | Default                   | What it does                                    |
| ----------------------------------------------------- | ------------------------- | ----------------------------------------------- |
| [`WORKFLOW_LOCAL_DATA_DIR`](#workflow_local_data_dir) | `.workflow-data/`         | Where the workflow database is stored           |
| [`PORT`](#port)                                       | auto-detected             | App port that queue messages are delivered to   |
| [`WORKFLOW_LOCAL_BASE_URL`](#workflow_local_base_url) | `http://localhost:{port}` | Base URL override for HTTPS or custom hostnames |

**Advanced**

| Variable                                                                                | Default                 | What it does                                     |
| --------------------------------------------------------------------------------------- | ----------------------- | ------------------------------------------------ |
| [`WORKFLOW_QUEUE_AUTH`](#workflow_queue_auth)                                           | `on`                    | Flow route accepts only the app's own deliveries |
| [`WORKFLOW_LOCAL_QUEUE_CONCURRENCY`](#workflow_local_queue_concurrency)                 | `1000`                  | Concurrent queue message handlers                |
| [`WORKFLOW_LOCAL_QUEUE_MAX_VISIBILITY`](#workflow_local_queue_max_visibility)           | unlimited               | Longest a queue message stays hidden             |
| [`WORKFLOW_LOCAL_HEADERS_TIMEOUT_MS`](#workflow_local_headers_timeout_ms)               | `0` ms (no deadline)    | Hung delivery detection                          |
| [`WORKFLOW_LOCAL_BODY_TIMEOUT_MS`](#workflow_local_body_timeout_ms)                     | `0` ms (no deadline)    | Stalled response detection                       |
| [`WORKFLOW_NODE_HTTP`](#workflow_node_http)                                             | disabled                | Deliveries through Node's built-in HTTP modules  |
| [`WORKFLOW_LOCAL_RECOVER_ACTIVE_RUNS`](#workflow_local_recover_active_runs)             | `true`                  | Re-enqueues active runs on start                 |
| [`WORKFLOW_LOCAL_SQLITE_KEEP_CONNECTIONS`](#workflow_local_sqlite_keep_connections)     | `1`; `brief` on Windows | How long the database connection stays open      |
| [`WORKFLOW_LOCAL_HOOK_RETENTION_LIMIT_DAYS`](#workflow_local_hook_retention_limit_days) | `30` days               | Maximum hook retention                           |
| [`WORKFLOW_STREAM_FLUSH_INTERVAL_MS`](#workflow_stream_flush_interval_ms)               | `0` ms                  | Stream write batching                            |

### `WORKFLOW_LOCAL_DATA_DIR`

- Default: `.workflow-data/`
- Factory option: `dataDir`

Directory for the workflow database, `world.db` (SQLite). See [Data directory layout](#data-directory-layout).

### `PORT`

- Default: auto-detected
- Factory option: `port`

The application dev server port. Used to deliver workflow queue messages to the combined flow route.

### `WORKFLOW_LOCAL_BASE_URL`

- Default: `http://localhost:{port}`
- Factory option: `baseUrl`

Full base URL override for HTTPS or custom hostnames.

Port resolution priority: `baseUrl` > `WORKFLOW_LOCAL_BASE_URL` > `port` > `PORT` > auto-detected

### `WORKFLOW_QUEUE_AUTH`

- Default: `on`

Whether the flow route accepts only deliveries sent by the app's own processes.

Change it when: a process that cannot read the app's data directory has to send deliveries, on a trusted machine only. Set `off` on the app. `off` is refused while dynamic workflows are enabled.

Every delivery carries the app's queue key, and the route refuses a request without it with a `401` and touches no run. The key is kept in the [data directory](#data-directory-layout), so point the CLI and the web UI at the app's data directory (`WORKFLOW_LOCAL_DATA_DIR`), and keep them on the same release as the app's `@workflow/world-local`: an older one sends no key.

A refused delivery is retried at once when the key in the file has changed, and otherwise a few times with a short backoff, then logged once and given up; its run is left as it was. See [`WORKFLOW_QUEUE_AUTH`](/docs/configuration/runtime-tuning#workflow_queue_auth).

### `WORKFLOW_LOCAL_QUEUE_CONCURRENCY`

- Default: `1000`

Maximum number of concurrent queue message handlers.

### `WORKFLOW_LOCAL_QUEUE_MAX_VISIBILITY`

- Default: unlimited

Maximum number of seconds a local queue message can stay hidden before the handler rechecks the run.

### `WORKFLOW_LOCAL_HEADERS_TIMEOUT_MS`

- Default: `0` (no deadline)

Maximum time in milliseconds to wait for a local queue handler to begin responding before redelivering the durable message.

Change it when: you would rather a hung handler be redelivered. Set it above the longest inline work you expect.

A delivery executes inline steps before the handler responds, so a deadline shorter than your longest step redelivers a healthy delivery while it is still running and executes the same step again.

### `WORKFLOW_LOCAL_BODY_TIMEOUT_MS`

- Default: `0` (no deadline)

Maximum gap in milliseconds between response body chunks from a local queue handler before redelivering the durable message.

The same caution as [`WORKFLOW_LOCAL_HEADERS_TIMEOUT_MS`](#workflow_local_headers_timeout_ms) applies.

### `WORKFLOW_NODE_HTTP`

- Default: disabled

Whether queue deliveries go out through Node's built-in `node:http` and `node:https` modules instead of the HTTP client library this World normally uses. Set to `1` to switch to Node's modules.

Socket pooling, keep-alive, and both timeouts above apply either way. See [`WORKFLOW_NODE_HTTP`](/docs/configuration/runtime-tuning#workflow_node_http) for what else changes.

### `WORKFLOW_LOCAL_RECOVER_ACTIVE_RUNS`

- Default: `true`
- Factory option: `recoverActiveRuns`

Whether pending and running runs found in the data directory are re-enqueued when the World starts. Set to `0` or `false` to skip recovery and leave stale runs untouched.

Change it when: several processes or workers run workflows on one data directory. Turn recovery off, or give each one its own `tag` (see [Programmatic configuration](#programmatic-configuration)).

The Local World's queue is in memory, so a restart loses the messages runs had queued. Recovery re-enqueues each run, and the recovery marker on the message makes that delivery send the run's step messages and wait timers (a `sleep()` or a timeout) again. As a backstop, recovery also sends each recovered run a wake for every open wait due within about 24.8 days (the queue's longest timer), due when the wait is.

A step that was running inline when the previous process exited runs again on the recovered delivery, and the interrupted attempt counts toward its retries. A step with `maxRetries: 0` that was interrupted mid-body therefore fails instead of running again.

> For runs started before v5.8.0, on Worlds without [spec version 9](/worlds/building-a-world#supporting-spec-9-runs), or with [`WORKFLOW_SPEC_VERSION=8`](/docs/configuration/runtime-tuning#workflow_spec_version), the recovered delivery re-arms the run's wait timers by suspending on its open waits again. Recovery also hands back to the queue any step that was running inline when the previous process exited, so the step runs again right away instead of after the inline-ownership lease (about 14 minutes). A step with `maxRetries: 0` that was interrupted mid-body fails on restart with an "exceeded max retries" error.

If you turn recovery off and re-enqueue runs yourself, call `releaseOrphanedSteps(runId)` before re-enqueueing each run. It is a method of `LocalWorld`, the type `createWorld()` from `@workflow/world-local` returns. The `World` type that `getWorld()` returns does not declare it, so a caller holding a `World` needs the `LocalWorld` type to call it.

A step counts as abandoned only if it started before the Local World loaded in the current process or worker thread. Steps started since then are never released, so runs this process picks up during or after recovery are not affected, and calling `releaseOrphanedSteps()` late is safe. Recovery assumes that nothing else is running workflows on the same data directory and `tag`. That includes an earlier worker thread of the same process: some dev servers reload into a new worker thread, and until the old one stops, the new one may dispatch a step the old one is still running, so the step can run twice.

### `WORKFLOW_LOCAL_SQLITE_KEEP_CONNECTIONS`

- Default: `1`, except on Windows, where it is `brief`

How long a process keeps its connection to `world.db` open between operations.

`1` keeps it until it has been idle for a few seconds. `brief` closes it once a burst of operations ends; it is the default on Windows, where an open database file cannot be deleted, so the data directory stays removable while the app runs. `0` opens and closes a connection for every operation, which is slower; the repository's own tests use it on Windows because they delete their data directory right after using it. Any other value, including `true` or `false`, uses the default.

### `WORKFLOW_LOCAL_HOOK_RETENTION_LIMIT_DAYS`

- Default: `30`

Maximum [`experimental_minRetention`](/docs/api-reference/workflow/create-hook#keep-a-token-unavailable-after-the-run-ends) accepted by the Local World, in days.

Change it when: your production World uses a different limit. Set the same limit so oversized values fail during local development.

### `WORKFLOW_STREAM_FLUSH_INTERVAL_MS`

- Default: `0` (dispatch immediately)
- Factory option: `streamFlushIntervalMs`

Group-commit window, in milliseconds, for the leading chunk of an idle stream.

A positive value holds the first chunk up to that long to collect a group, trading first-chunk latency for fewer requests. Chunks arriving while a request is in flight always coalesce into the next group regardless.

### Programmatic configuration

Options passed to `createWorld()` take precedence over the environment variables above. Export the configured World from a module and point `WORKFLOW_TARGET_WORLD` at that module:

```typescript title="my-world.ts" lineNumbers
import { createWorld } from "@workflow/world-local";

export default createWorld({
  dataDir: "./custom-workflow-data",
  port: 5173,
  // baseUrl overrides port if set
  baseUrl: "https://local.example.com:3000",
  recoverActiveRuns: true, // overrides WORKFLOW_LOCAL_RECOVER_ACTIVE_RUNS
  streamFlushIntervalMs: 10, // WORKFLOW_STREAM_FLUSH_INTERVAL_MS, if set, overrides this
});
```

```bash title=".env"
WORKFLOW_TARGET_WORLD="./my-world.ts"
```

`createWorld()` also accepts `tag`, which scopes the runs and streams a World writes, and which runs its startup recovery re-enqueues, so several Worlds can share one data directory without seeing each other's data. A tagged World also reads untagged runs, and its `clear()` deletes only its own data. It is mainly used by test harnesses that share one `.workflow-data` directory with the app.

### Queue consumers other than the Workflow SDK

The Local World delivers queue messages over HTTP to the app, and by default every message goes to the Workflow SDK's flow route, `/.well-known/workflow/v1/flow`. A library that consumes messages of its own on the same World, such as a durable agent harness, uses its own queue prefix (`__{namespace}_wkf_workflow_`) and tells the World where those go:

```typescript title="lib/agent-queue.ts" lineNumbers
import { getWorld } from "workflow/runtime";

const PREFIX = "__agent_wkf_workflow_";

export async function registerAgentQueue(
  handler: (req: Request) => Promise<Response>
) {
  const world = await getWorld();
  // Over HTTP: deliveries for this prefix go to the app's own route.
  world.registerRoute?.(PREFIX, "/api/agent/queue");
  // In this process: deliveries skip HTTP entirely.
  world.registerHandler?.(PREFIX, handler);
}
```

`registerHandler()` takes precedence over `registerRoute()` for the same prefix. A prefix with neither still goes to the flow route, which answers `400` for a prefix it does not handle, and the Local World retries the message every five seconds, so a route registered later takes the next attempt. When the World restarts, `start()` re-enqueues each active run to the queue namespace it recorded at creation (`executionContext.queueNamespace`), so register the route or handler before calling `start()`.

## Data directory layout

Everything the Local World stores is in one SQLite database, `world.db` in the data directory (with SQLite's `world.db-wal` and `world.db-shm` files next to it): runs, their event logs, steps, waits, hooks, stream chunks and snapshots. Queue messages are not stored: a message is an HTTP request to the app (or a call to an in-process handler) made by the process that enqueued it, held only in that process's memory while it waits for a delay or a retry. It is opened with the runtime's built-in driver, `node:sqlite` on Node.js 22.13 or later and `bun:sqlite` on Bun, so there is no native dependency to install. Node.js 22.x still marks `node:sqlite` as experimental; the World drops the `ExperimentalWarning` it prints for that, and only that one.

Each World write is one transaction: an event and every change it makes to its run, step, wait and hook commit together or not at all, so a process that is killed mid-write leaves nothing half-written behind. Several processes can use one data directory at once (an app and a test runner, say). SQLite orders their writes, and the lock it takes is released by the operating system when a process exits, however it exits.

To look at the data directly, open it with any SQLite client:

```bash
sqlite3 .workflow-data/world.db "select seq, event_type, correlation_id from events where run_id = 'wrun_…' order by seq"
```

Earlier releases stored one JSON file per entity (`runs/`, `events/`, `steps/`, `hooks/`, `.locks/` and so on). That data is not migrated, and it is not deleted either: the World leaves those directories where they are, does not read them, and starts with an empty database next to them. When `world.db` is created in a data directory that still holds them, the World says so once in the log, naming the directories. Delete them by hand once you no longer need them. Older releases do not read `world.db`, so runs created with this release are not visible after a downgrade, and a `world.db` written by a newer release is refused rather than read.

The database needs a filesystem that supports SQLite's shared-memory file. A data directory on a network filesystem (NFS, SMB), or shared between a host and a container through a VM-backed mount, is not supported when more than one machine or VM writes to it.

The data directory also holds the app's queue key, `queue-auth-key` (see [`WORKFLOW_QUEUE_AUTH`](#workflow_queue_auth)), a random value. The app writes a new one each time it starts, when it first uses its World and before it sends anything, so a restart needs no wait. A script that calls `start()` with the same data directory writes a new key the same way, and the app accepts it. The CLI and the web UI only read the key. Several app processes on one data directory (PM2 with `-i N`, `node:cluster`, Nitro's `node-cluster` preset) end up on the newest key in the file. The file is readable and writable only by its owner (mode `0600`); Windows does not enforce that mode the same way, and the file gets the directory's permissions. The World writes a `.gitignore` containing `*` into the data directory when it has none, so neither the key nor the run data is committed, and never replaces one that is already there.

## Limitations

The Local World is designed for development, not production:

- **In-memory queue**: Queue messages, including delayed ones and retries, do not survive a restart. Startup recovery re-enqueues active runs, which re-arms their open waits. A process that exits right after sending a message (the CLI, a script) gives the app up to 10 seconds to take it.
- **Single machine**: The data directory is a local SQLite database, so the Local World cannot handle distributed deployments.
- **Minimal authentication**: The flow route accepts only deliveries carrying the app's queue key (see [`WORKFLOW_QUEUE_AUTH`](#workflow_queue_auth)), but nothing else is authenticated. Anyone who can read the data directory can read the key. The Local World is suitable only for local development.

For production deployments, use the [Vercel World](/worlds/vercel), which handles execution, persistence, multi-tenancy, scale, observability, and security for you on Vercel, or check out the [Postgres World](/worlds/postgres) - a tested reference implementation that implements the complete World spec and can be used to deploy workflows anywhere.

---

For a semantic overview of all documentation, see [/sitemap.md](/sitemap.md)

For an index of all available documentation, see [/llms.txt](/llms.txt)

For agent-facing discovery, including API and MCP surfaces, see [/agents.md](/agents.md)