Skip to content

Installation

anarchon comes as the anarchon package on npm (Node.js 20 or newer) and as the Anarchon packages on NuGet (.NET 10). Pick your language; the tab you pick holds for every page.

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

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 NATS NatsBackend with its lease strategy (strategy: 'lease', NatsStrategy.Lease) The full feature set, on a JetStream key-value bucket
Only RabbitMQ RabbitMQBackend One winner per run, but no backups, overlap protection or catch-up

Backends overview compares them in detail.

Node.js only: 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');

It uses a SQLite file, so it needs no server.

Save this as check.mjs and run node check.mjs (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.