# Runtime

The `craft` CLI runs on Bun. Routecraft itself is also a library, so Node users embed it programmatically.

## CLI runtime: Bun

The `craft` bin ships with a `#!/usr/bin/env bun` shebang. `bunx craft`, `bun run start`, and `craft` all execute under Bun natively. There is no Node fallback and no tsx bridge.

### Version floor

Routecraft requires **Bun 1.1.0 or later**. The CLI checks `process.versions.bun` at startup and exits with a clear error message if Bun is missing or below the floor.

```
$ craft run index.ts
[routecraft] Bun 1.0.0 is not supported. Routecraft requires Bun 1.1.0 or
later. Upgrade Bun: https://bun.com/docs/installation.
```

If Bun is not installed at all, the OS resolves `env bun` and reports `bun: command not found`. The CLI cannot start without Bun.

### Why Bun-only

Bun has native TypeScript support, which means the CLI can load `.ts` capability files directly with no `tsc` step and no tsx loader bridge. Bun also provides built-in drivers (`Bun.sql`, `Bun.s3`, `bun:sqlite`, native YAML and TOML parsers) that adapters can use without pulling in extra dependencies. Standardising on Bun for the CLI lets every adapter rely on those primitives and keeps the install footprint small.

## Embedding in Node

Users who want to run Routecraft inside a Node application embed the library directly instead of going through the CLI. The library itself works on **Node 22.6 or later** (for runtime type stripping) and is recommended on **Node 23.6 or later** where stripping is on by default.

The features that keep state in SQLite behave differently on Node. The telemetry SQLite sink, the deferral store behind durable agents, and the agent session store use `bun:sqlite` under Bun and the optional peer `better-sqlite3` under Node. Without that peer on Node, a store left at its default logs a warning and degrades: the telemetry sink switches off, and the deferral and session stores fall back to memory, so their state does not survive a restart. A store given an explicit path (`deferral: { store }`, `sessions: { store }`) fails the context at startup instead, so a deployment that asked for durability never runs without it. Install `better-sqlite3` on Node, and for production telemetry under either runtime, configure an OTLP exporter (Datadog, Honeycomb, Better Stack, etc.) through `telemetry: { tracerProvider }` in `defineConfig`.

[Programmatic invocation](/docs/advanced/programmatic-invocation) is the embedding guide: building a context, dispatching to capabilities, and wiring Routecraft into Express, Next.js, or Commander.

## Choosing a runtime

| Use case | Runtime | How to run |
| --- | --- | --- |
| Running a project scaffolded by `create-routecraft` | Bun | `bun run start` |
| Quick `.ts` script | Bun | `bunx craft run capabilities/my-route.ts` |
| Embedded inside an existing Node application | Node 22.6+ | Import `@routecraft/routecraft`; do not invoke the CLI |
| Embedded inside a Bun application | Bun | Import `@routecraft/routecraft`; do not invoke the CLI |

---

## Related

- [Programmatic invocation](/docs/advanced/programmatic-invocation) -- Embed Routecraft inside a Node or Bun application and dispatch to capabilities from code.
- [Deployment](/docs/introduction/deployment) -- Run in production on Bun with the CLI, or embedded in a Node application.
- [Installation](/docs/introduction/installation) -- System requirements and creating a project.
