Nuxt Scheduler
Schedule Jobs within Nuxt 3.
Features
- 👩🏼🌾 human readable
- 😌 easy to use
Quick Setup
- Add
nuxt-scheduler
dependency to your project
pnpm add -D nuxt-scheduler
yarn add --dev nuxt-scheduler
npm install --save-dev nuxt-scheduler
- Add
nuxt-scheduler
to the modules
section of nuxt.config.ts
export default defineNuxtConfig({
modules: [
'nuxt-scheduler'
]
})
That's it! You can now use Nuxt Scheduler in your Nuxt app ✨
Example Usage
You must create a file here
~/server/app/scheduler.ts
import { useScheduler } from "#scheduler";
import say from "~/server/app/services/say";
export default function startScheduler() {
const scheduler = useScheduler();
scheduler.start();
scheduler.run(() => {
say("this should run every 5 seconds");
}).everySeconds(5);
}
use Human Readable intervals
everySecond
everySeconds(5)
everyMinute
everyMinutes(17)
everyTwoMinutes
everyThreeMinutes
everyFourMinutes
everyFiveMinutes
everyTenMinutes
everyFifteenMinutes
everyThirtyMinutes
hourly
hourlyAt
everyOddHour
everyHours
everyTwoHours
everyThreeHours
everyFourHours
everySixHours
daily
dailyAt
everyDays
weekly
quarterly
yearly
cron
or set using cron syntax
setRawInterval('* * * * *')
Development
npm install
npm run dev:prepare
npm run dev
npm run dev:build
npm run lint
npm run test
npm run test:watch
npm run release