Advanced

Deployment

Deploy Routecraft on Bun for the CLI path, or embed it inside a Node application.

Choose a path

PathWhenRuntime on host
Bun CLICapabilities are the whole app and craft run is the entry point. Default for projects scaffolded by create-routecraft.Bun >= 1.1.0
Node embeddingRoutecraft runs inside an existing Node service (Express, Next.js, Fastify, a worker). The CLI is not used.Node >= 22.6

The two paths can be mixed within the same project. See the Runtime reference for the rationale.

Bun CLI on a server

Routecraft's craft bin requires Bun on the host. Add a start script:

{
  "scripts": {
    "start": "craft run ./capabilities/index.ts"
  }
}

Then run bun run start. Any provider that lets you install Bun (a long-running container, a VM, or a Bun-native runtime) will work.

Docker (Bun base image)

Use a two-stage image with the official Bun base:

# 1) Dependencies
FROM oven/bun:1 AS deps
WORKDIR /app
COPY package.json bun.lock ./
RUN bun install --frozen-lockfile --production

# 2) Production runtime
FROM oven/bun:1-slim
WORKDIR /app
ENV NODE_ENV=production
COPY --from=deps /app/node_modules ./node_modules
COPY package.json ./
COPY capabilities ./capabilities

CMD ["bun", "run", "start"]

If your project uses pnpm or npm for dependency management, swap the install command in the deps stage (pnpm install --frozen-lockfile --prod or npm ci --omit=dev) but keep the CMD ["bun", "run", "start"] line — the runtime requirement is unchanged.

Node embedding on a server

When you embed @routecraft/routecraft inside a Node service, deploy it the same way you would any Node application: build the service (or use Node's runtime type stripping on Node 22.6+), then run it with node. No Bun on the host.

FROM node:22-alpine
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --omit=dev
COPY . .
CMD ["node", "--experimental-strip-types", "src/server.ts"]

The Node 23.6+ image enables type stripping by default; drop the flag in that case.

See the Programmatic Invocation guide for the embedding API and runnable examples.


Runtime reference

Bun-only CLI, Node embedding, version floors.

CLI reference

All craft CLI commands including run.

Programmatic Invocation

Embed Routecraft inside Node, Express, or Next.js.

Previous
Testing