croner is a free, open source scheduling & event management project written in TypeScript and released under MIT. It has 2,592 GitHub stars, 68 forks and 3 open issues, and was last pushed 17 days ago. On this registry it ranks #9 of 23 tracked projects in Scheduling & Event Management, with 5 head-to-head comparisons available.

What is croner?

What it is

Croner is a JavaScript and TypeScript library for working with cron expressions. It lets developers trigger functions on a schedule or evaluate cron patterns to find upcoming run times, match dates, and calculate intervals. The project lives in the JavaScript runtime ecosystem and is designed for Node.js, Deno, Bun, and browser environments.

The concrete problem it solves is adding cron-style scheduling directly inside an application without adding extra packages. It provides a programmatic way to run repeated jobs, one-off date-based tasks, and timezone-aware checks from code. Because it operates in memory and has no dependencies, it can be embedded in a service, script, or web page where a lightweight scheduling mechanism is needed.

Key capabilities

  • Croner can trigger a function at each time matching a cron expression, including second-level and yearly patterns.
  • It can evaluate cron expressions and return upcoming run times, such as the next 100 Sundays, without starting a job.
  • It supports extended cron syntax features, including seconds, year fields, L, W, #, and + logic.
  • It can run scheduled functions in a specified time zone, using ISO 8601 local time or cron patterns with timezone options.
  • It includes built-in overrun protection and error handling for scheduled functions.
  • It supports asynchronous functions and lets users pause, resume, or stop execution after a task is scheduled.
  • It includes TypeScript typings and works through require, import, UMD, ES-module, and CDN usage.

Who uses it and how

  • Application developers embed Croner in Node.js, Deno, or Bun services to run recurring tasks from code.
  • Browser and web-page users load it as a UMD or ES-module script to evaluate cron patterns or schedule functions in client-side JavaScript.
  • Developers use it to enumerate future run times and check whether a date matches a cron pattern.
  • Developers of timezone-sensitive jobs use it to fire tasks at a specific local time in another region, such as Asia/Kolkata.
  • Projects that need in-memory scheduling without database or configuration files use it for cron-style job execution.

Getting started

Typical installation is through npm, JSR, a package manager, or a CDN, then importing Cron in Node.js, Bun, Deno, or browser code. Deno users can import from deno.land/x or jsr:@hexagon/croner, while web pages can include the UMD module.

When to use it — and when not to

Croner is useful when a JavaScript or TypeScript application needs lightweight, dependency-free cron scheduling inside the process. It is not the right fit when the application cannot rely on in-memory scheduling, because it operates without a database or configuration files. It also requires the surrounding application to provide the runtime, because it is an embedded library.

project readme (upstream, from github) — read inline

Croner
Trigger functions or evaluate cron expressions in JavaScript or TypeScript. No dependencies. All features. Node. Deno. Bun. Browser.

Try it live on jsfiddle, and check out the full documentation on croner.56k.guru.

Croner - Cron for JavaScript and TypeScript

npm version JSR NPM Downloads No dependencies MIT License

  • Trigger functions in JavaScript using Cron syntax.
  • Evaluate cron expressions and get a list of upcoming run times.
  • Supports seconds and year fields, L (last), W (weekday), # (nth occurrence), and + (AND logic).
  • Works in Node.js >=18.0 (both require and import), Deno >=2.0 and Bun >=1.0.0.
  • Works in browsers as standalone, UMD or ES-module.
  • Target different time zones.
  • Built-in overrun protection
  • Built-in error handling
  • Includes TypeScript typings.
  • Support for asynchronous functions.
  • Pause, resume, or stop execution after a task is scheduled.
  • Operates in-memory, with no need for a database or configuration files.
  • Zero dependencies.

Quick examples:

// Basic: Run a function at the interval defined by a cron expression
const job = new Cron('*/5 * * * * *', () => {
	console.log('This will run every fifth second');
});

// Enumeration: What dates do the next 100 sundays occur on?
const nextSundays = new Cron('0 0 0 * * 7').nextRuns(100);
console.log(nextSundays);

// Days left to a specific date
const msLeft = new Cron('59 59 23 24 DEC *').nextRun() - new Date();
console.log(Math.floor(msLeft/1000/3600/24) + " days left to next christmas eve");

// Run a function at a specific date/time using a non-local timezone (time is ISO 8601 local time)
// This will run 2024-01-23 00:00:00 according to the time in Asia/Kolkata
new Cron('2024-01-23T00:00:00', { timezone: 'Asia/Kolkata' }, () => { console.log('Yay!') });

// Check if a date matches a cron pattern
const mondayCheck = new Cron('0 0 0 * * MON');
console.log(mondayCheck.match('2024-01-01T00:00:00')); // true  (Monday)
console.log(mondayCheck.match('2024-01-02T00:00:00')); // false (Tuesday)

More examples...

Installation

Full documentation on installation and usage is found at

Note If you are migrating from a different library such as cron or node-cron, or upgrading from a older version of croner, see the migration section of the manual.

Install croner using your favorite package manager or CDN, then include it in you project:

Using Node.js or Bun

// ESM Import ...
import { Cron } from "croner";

// ... or CommonJS Require, destructure to add type hints
const { Cron } = require("croner");

Using Deno

// From deno.land/x
import { Cron } from "https://deno.land/x/[email protected]/dist/croner.js";

// ... or jsr.io
import { Cron } from "jsr:@hexagon/[email protected]";

In a webpage using the UMD-module

<script src="https://cdn.jsdelivr.net/npm/croner@10/dist/croner.umd.min.js"></script>

Documentation

Signature

Cron takes three arguments

// Parameters
// - First: Cron pattern, js date object (fire once), or ISO 8601 time string (fire once)
// - Second: Options (optional)
// - Third: Function run trigger (optional)
const job = new Cron("* * * * * *", { maxRuns: 1 }, () => {} );

// If function is omitted in constructor, it can be scheduled later
job.schedule(job, /* optional */ context) => {});

The job will be sceduled to run at next matching time unless you supply option { paused: true }. The new Cron(...) constructor will return a Cron instance, later called job, which have a couple of methods and properties listed below.

Status
job.nextRun( /*optional*/ startFromDate );	// Get a Date object representing the next run.
job.nextRuns(10, /*optional*/ startFromDate ); // Get an array of Dates, containing the next n runs.
job.previousRuns(10, /*optional*/ referenceDate ); // Get an array of Dates, containing previous n scheduled runs.
job.msToNext( /*optional*/ startFromDate ); // Get the milliseconds left until the next execution.
job.currentRun(); 		// Get a Date object showing when the current (or last) run was started.
job.previousRun( ); 		// Get a Date object showing when the previous job was started.

job.match( date ); 		// Check if a Date object or date string matches the cron pattern (true or false).

job.isRunning(); 	// Indicates if the job is scheduled and not paused or killed (true or false).
job.isStopped(); 	// Indicates if the job is permanently stopped using `stop()` (true or false).
job.isBusy(); 		// Indicates if the job is currently busy doing work (true or false).

job.getPattern(); 	// Returns the original pattern string
job.getOnce(); 		// Returns the original run-once date (Date or null)
Control functions
job.trigger();		// Force a trigger instantly
job.pause();		// Pause trigger
job.resume();		// Resume trigger
job.stop();		// Stop the job completely. It is not possible to resume after this.
				// Note that this also removes named jobs from the exported `scheduledJobs` array.
Properties
job.name 			// Optional job name, populated if a name were passed to options
Options
Key Default value Data type Remarks
name undefined String If you specify a name for the job, Croner will keep a reference to the job in the exported array scheduledJobs. The reference will be removed on .stop().
maxRuns Infinite Number
catch false Boolean|Function Catch unhandled errors in triggered function. Passing true will silently ignore errors. Passing a callback function will trigger this callback on error.
timezone undefined String Timezone in Europe/Stockholm format
startAt undefined String ISO 8601 formatted datetime (2021-10-17T23:43:00)
in local time (according to timezone parameter if passed)
stopAt undefined String ISO 8601 formatted datetime (2021-10-17T23:43:00)
in local time (according to timezone parameter if passed)
interval 0 Number Minimum number of seconds between triggers.
paused false Boolean If the job should be paused from start.
context undefined Any Passed as the second parameter to triggered function
domAndDow false boolean Combine day-of-month and day-of-week using true = AND, false = OR (default)
legacyMode (deprecated) boolean Deprecated: Use domAndDow instead. Inverse of domAndDow (legacyMode: true = domAndDow: false).
unref false boolean Setting this to true unrefs the internal timer, which allows the process to exit even if a cron job is running.
utcOffset undefined number Schedule using a specific utc offset in minutes. This does not take care of daylight savings time, you probably want to use option timezone instead.
protect undefined boolean|Function Enabled over-run protection. Will block new triggers as long as an old trigger is in progress. Pass either true or a callback function to enable
alternativeWeekdays false boolean Enable Quartz-style weekday numbering (1=Sunday, 2=Monday, ..., 7=Saturday). When false (default), uses standard cron format (0=Sunday, 1=Monday, ..., 6=Saturday).

Warning Unreferencing timers (option unref) is only supported by Node.js and Deno. Browsers have not yet implemented this feature, and it does not make sense to use it in a br

readme truncated — read the full docs on github

Frequently asked questions

Is croner free to use?

croner is open source under the MIT licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does croner do?

Trigger functions or evaluate cron expressions in JavaScript or TypeScript. No dependencies. Most features. Node. Deno. Bun. Browser.

What is croner written in?

croner is primarily written in TypeScript. Its source is publicly available at https://github.com/Hexagon/croner, and it has 2,592 GitHub stars.