Repolode
Hexagon

Hexagon/croner

A zero-dependency TypeScript/JavaScript cron library to schedule functions or compute upcoming run times on Node, Deno, Bun and browsers.

Stars
2,611
Forks
75
Open issues
7
Last commit
4 days ago

What is it?

Croner lets JavaScript and TypeScript code run functions on a cron schedule, or evaluate a cron expression to list upcoming run times and check whether a date matches a pattern. It runs in memory with no database or configuration files, and works in Node.js, Deno, Bun and browsers.

Beyond standard cron syntax, it supports an optional seconds field and year field, along with L (last day or weekday), W (nearest weekday), # (nth weekday of the month) and + (AND logic between day-of-month and day-of-week). Jobs can target specific time zones, be paused, resumed or stopped, and be given a maximum run count or a start and stop time.

Runtime safeguards include over-run protection that blocks new triggers while a previous async task is still running, configurable error catching, and an option to unref timers so Node or Deno processes can exit. Type definitions are included.

Key features

  • 01Schedules functions with cron expressions that include optional seconds and year fields.
  • 02Lists upcoming and previous run times, and checks whether a date matches a pattern.
  • 03Supports time zones, L, W, # and + modifiers, and Quartz-style weekday numbering.
  • 04Built-in over-run protection for async tasks and configurable error handling.
  • 05Zero dependencies, with TypeScript typings included.

Use cases

  • Running periodic background jobs inside a Node.js or Bun server without a separate scheduler service.
  • Calculating the next several run times of a schedule to display in a UI.
  • Scheduling tasks in a specific time zone for users in different regions.
  • Running cron-style timers in a Deno or browser environment.

Quick start

  1. 1

    Install croner from npm

    npm install croner
  2. 2

    Import the Cron class in your project

    import { Cron } from "croner";
  3. 3

    Schedule a function with a cron pattern

    new Cron('*/5 * * * * *', () => { console.log('This will run every fifth second'); });

Things to know

  • Timers only run while the host process is alive, since everything is in-memory.

Topics

FAQ

What is croner?
A zero-dependency TypeScript/JavaScript cron library to schedule functions or compute upcoming run times on Node, Deno, Bun and browsers. Croner lets JavaScript and TypeScript code run functions on a cron schedule, or evaluate a cron expression to list upcoming run times and check whether a date matches a pattern. It runs in memory with no database or configuration files, and works in Node.js, Deno, Bun and browsers.
Is croner free to use? What license does it have?
croner is open source under the MIT license. Check the license terms before using it in commercial products.
Is croner still maintained?
Actively maintained. The last commit to croner was on Oct 18, 2026.
What can I use croner for?
Running periodic background jobs inside a Node.js or Bun server without a separate scheduler service. Calculating the next several run times of a schedule to display in a UI. Scheduling tasks in a specific time zone for users in different regions. Running cron-style timers in a Deno or browser environment.
How do I install croner?
Install croner from npm: npm install croner Import the Cron class in your project: import { Cron } from "croner"; Schedule a function with a cron pattern: new Cron('*/5 * * * * *', () => { console.log('This will run every fifth second'); });
Where can I get croner?
The source code and installation instructions are on GitHub: https://github.com/Hexagon/croner

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects