Skip to content

Installation

anarchon needs Node.js 20 or newer.

Install anarchon and the driver for your store. Drivers are optional peer dependencies, so you only install the one you use.

Terminal window
pnpm add anarchon redis

Works with Redis 5 or newer and with Valkey. redis (node-redis) is only needed if anarchon opens the connection for you. You can pass a client your app already has instead: ioredis, iovalkey, node-redis or Valkey GLIDE.

npm install and yarn add work the same way.

Use the one your service already has. If you have a choice:

You have Use Why
Redis or Valkey The default, lease strategy The full feature set, and the least latency
PostgreSQL, no Redis PostgresBackend The full feature set, with no new infrastructure
One machine, several processes SqliteBackend on a file No server at all
Only RabbitMQ or NATS RabbitMQBackend / NatsBackend One winner per run, but no backups, overlap protection or catch-up

Backends overview compares them in detail.

anarchon is written in TypeScript and ships its own types. There is nothing extra to install.

import { Scheduler, type JobContext, type RunRecord } from 'anarchon';

It also works from plain JavaScript, with require or import:

const { Scheduler } = require('anarchon');

Save this as check.mjs and run node check.mjs. It uses a SQLite file, so it needs no server (Node 22.13 or newer).

import { Scheduler, SqliteBackend } from 'anarchon';
const scheduler = new Scheduler({ backend: new SqliteBackend({ database: './anarchon.db' }) });
scheduler.every('hello', '2s', (ctx) => console.log('hello at', ctx.scheduledAt.toISOString()));
await scheduler.start();
setTimeout(() => scheduler.stop(), 7_000);

You should see a line every two seconds, then the process exits.

Quick start builds a small scheduler and runs it as three instances.