@nestjs/schedule

Declarative cron, interval, and timeout job scheduling for NestJS applications via decorators.

Library
npm
v12.0.2
427 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
83 /100 Excellent
Development Activity 96
Maintenance 84
Community 64
Maturity 60
Momentum 28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
83 /100 Excellent
Architecture 84
Code Quality 85
Innovation 74
Learning Curve 88

@nestjs/schedule is the official NestJS module for running scheduled tasks, built on top of the cron package. It lets developers annotate provider methods with @Cron(), @Interval(), or @Timeout() decorators and have the framework register, start, and manage those jobs automatically as part of the application lifecycle.

Under the hood, a ScheduleExplorer scans providers at bootstrap for decorated methods and hands them to a SchedulerRegistry/SchedulerOrchestrator, which tracks live cron jobs, intervals, and timeouts so they can be looked up, dynamically added, or stopped at runtime via dependency injection — rather than living as free-standing timers outside the framework’s control.

What You Get

  • @Cron() decorator for cron-expression-based recurring jobs, including named jobs and timezone/UTC-offset options
  • @Interval() and @Timeout() decorators for simpler recurring or delayed execution
  • A SchedulerRegistry service for looking up, adding, or deleting cron jobs, intervals, and timeouts at runtime
  • Automatic discovery of decorated methods across all providers via ScheduleExplorer at application bootstrap
  • A ScheduleModule.forRoot() entrypoint that wires scheduling into the Nest module graph
  • Dynamic module support for registering jobs outside of decorators when schedules are computed at runtime

Common Use Cases

  • Running periodic maintenance tasks (cache cleanup, session expiry, report generation) inside a Nest backend
  • Polling external APIs or databases on a fixed interval from within a Nest service
  • Firing one-off delayed jobs after application startup via @Timeout()
  • Building admin tooling that lists, pauses, or reschedules cron jobs at runtime through the SchedulerRegistry

Under The Hood

Architecture — lib/schedule.module.ts exposes a ScheduleModule.forRoot() dynamic module that wires together three collaborators: ScheduleExplorer walks the Nest module/provider graph at bootstrap (via DiscoveryService/MetadataScanner) looking for methods carrying SCHEDULE_CRON_OPTIONS/interval/timeout metadata set by the decorators; SchedulerRegistry is the injectable public API for looking up and mutating jobs by name; and SchedulerOrchestrator holds the actual live CronJob/timer instances and starts/stops them in response to lifecycle hooks (OnApplicationBootstrap, OnApplicationShutdown). Tech Stack — TypeScript targeting the Nest 11.x peer dependencies (@nestjs/common/@nestjs/core), with a single runtime dependency on the cron npm package for cron-expression parsing and timezone handling; builds with tsc, lints with oxlint, and tests with vitest (migrated off Jest). Code Quality — tests/ contains integration tests that boot a real Nest TestingModule and assert jobs get registered/executed, rather than only unit-testing decorators in isolation; the schedule.messages.ts module centralizes user-facing error strings for consistency; commit history shows steady dependency bumps via Renovate alongside human-authored feature/fix commits. API Design — decorators (@Cron(CronExpression.EVERY_MINUTE), @Interval(1000), @Timeout(5000)) read as plain annotations on ordinary provider methods, so adopting scheduling requires no boilerplate beyond importing ScheduleModule.forRoot() once; the CronExpression enum spares users from memorizing raw cron syntax for common schedules, and SchedulerRegistry gives an escape hatch to imperative control when the declarative decorator model isn’t enough.

Used by 18 apps in this directory

TypeScript
94%
AGPL 3.0

Laudspeaker

Automation · Marketing

2,629

Open-source customer engagement platform for building visual, event-triggered messaging journeys across email, SMS, push, in-app, and webhooks.

View details
45
Repo Health
66
Technical
62
Dependency
Built with
TypeScript 94%
Updated 3 months ago
TypeScript
65%
Other

NocoDB

Databases · Low Code Platforms · No Code Platforms

65,340

Turn any SQL database into a collaborative no-code spreadsheet with automatic REST APIs and real-time views.

View details
91
Repo Health
77
Technical
63
Dependency
Built with
TypeScript 65%
Vue 30%
Updated 6 days ago
TypeScript
98%
Other

Novu

Developer Tools

40,195

Open-source communication infrastructure that connects your products and AI agents to every channel your users live on — Inbox, Email, SMS, Push, Chat, and more.

View details
93
Repo Health
80
Technical
64
Dependency
Built with
TypeScript 98%
Updated 6 days ago
TypeScript
81%
AGPL 3.0

Postiz

Automation · Social Media

37,683

The agentic social media scheduler — AI-powered content creation, 33-platform posting, and team workflows, all self-hosted.

View details
92
Repo Health
70
Technical
63
Dependency
Built with
TypeScript 81%
JavaScript 11%
Updated 1 weeks ago
TypeScript
96%
Other

Refly

AI Development · Automation · No Code Platforms

7,537

Build deterministic, versioned agent skills from natural language—run them anywhere from Claude Code to Slack.

View details
68
Repo Health
76
Technical
63
Dependency
Built with
TypeScript 96%
Updated 1 weeks ago
TypeScript
97%
AGPL 3.0

Swetrix

Analytics

1,213

Privacy-first, cookieless web analytics with error tracking, session replays, and performance monitoring — self-host or use Cloud.

View details
87
Repo Health
71
Technical
66
Dependency
Built with
TypeScript 97%
Updated 1 weeks ago
HTML
68%
AGPL 3.0

ToolJet

AI Agents · Low Code Platforms · No Code Platforms

41,123

Open-source AI-native platform to build and deploy internal tools, workflows, and AI agents with a visual drag-and-drop builder and 80+ data source integrations.

View details
94
Repo Health
81
Technical
63
Dependency
Built with
HTML 68%
JavaScript 20%
Updated 6 days ago
TypeScript
79%
MIT

Trench

Analytics · Data Engineering · Monitoring

1,665

Open-source event tracking infrastructure built on Kafka and ClickHouse that handles thousands of events per second on a single node, with full Segment API compatibility and no cookies.

View details
44
Repo Health
81
Technical
73
Dependency
Built with
TypeScript 79%
MDX 15%
Updated 6 months ago
TypeScript
84%
Other

twenty

CRM

59,615

The open-source CRM you build, ship, and version like the rest of your stack — with customizable objects, AI agents, and a TypeScript SDK.

View details
92
Repo Health
82
Technical
64
Dependency
Built with
TypeScript 84%
MDX 14%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers