Crux
GuidesRuntime Engine

Long-lived Node Runtime

Use node() for local development, tests, and durable multi-worker Node processes.

node() is the in-process Runtime Engine composer. With no options it uses the in-memory reference store, which is ideal for tests and local development but not durable across process restarts.

Local development

import { config } from '@use-crux/core'
import { node } from '@use-crux/core/runtime'

export default config({
  runtime: node(),
})

This supports runtime-bound APIs in one process: event waits, timers, deferred tasks, scoped idle, and automatic signal resume.

Durable Node

Use a durable store for long-lived workers or multiple Node processes:

import { config } from '@use-crux/core'
import { node } from '@use-crux/core/runtime'
import { postgres } from '@use-crux/postgres/runtime'

export default config({
  runtime: node({
    store: postgres({ url: process.env.DATABASE_URL }),
    retention: {
      terminalWork: '7d',
      terminalSnapshots: '30d',
    },
  }),
})

Run setup before deployment:

crux runtime setup --check

Maintenance

node() starts the maintenance loop by default. It dispatches pending outbox rows, scans due timers, reclaims expired leases, expires waiters, resolves scoped idle, and prunes retained terminal records.

Outbox delivery is bounded and defaults to eight in-flight wake deliveries per maintenance pass.

For tests or custom hosts, disable auto-start and call maintenance explicitly through the resolved runtime:

const runtime = createRuntime({
  runtime: node({ autoStartMaintenance: false }),
  targets: runtimeTargetMap([reviewFlow, embedDocument]),
})

await runtime.maintenance.tick()

On this page