百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
N

nuxt-cron

> 前端框架
开源

一个用于在应用中执行 cron 任务的 Nuxt 模块。

99 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

一个用于在应用中执行 cron 任务的 Nuxt 模块。

Nuxt Cron

npm version npm downloads License

A Nuxt module for cron jobs in your app.

  • Documentation
  • Playground
  • ✨ Releases

Features

  •   19 time presets
  • ️  Time zone support
  • ️  TypeScript support
  • ✨  Auto imports enabled
  • ⚡  Zero configuration to start
  •   Nuxt 3/4 support
  •   Extendable by Nuxt modules

Installation

bash
# Using pnpm
pnpm add nuxt-cron -D

# Using yarn
yarn add nuxt-cron -D

# Using npm
npm install nuxt-cron -D

Usage

Setup

Add nuxt-cron to the modules section of nuxt.config.ts

javascript
export default defineNuxtConfig({
  modules: ['nuxt-cron']
})

Configuration

You can configure the module by adding a nuxt-cron section to your nuxt.config file.

javascript
export default defineNuxtConfig({
  cron: {
    runOnInit: true,
    timeZone: 'Africa/Abidjan',
    jobsDir: 'cron'
  }
})

by default, nuxt-cron will auto-import your cron from the models directory from server directory. You can change this behavior by setting the jobsDir option.

API

defineCronHandler

This function creates a new cron job. Example usage:

typescript
// server/cron/job.ts
import { defineCronHandler } from '#nuxt/cron'

export default defineCronHandler('everySecond', () => {
  console.log('I run every seconds')
})

or use with params:

typescript
// server/cron/job.ts
import { defineCronHandler } from '#nuxt/cron'

export default defineCronHandler('everySecond', () => {
  console.log('I run every seconds')
}, { runOnInit: true })

More examples can be found here.

Credits

A huge thank you to everyone who is helping to improve nuxt-cron. Thanks to you, the project can evolve!

Contributors

To become a contributor, please follow our contributing guide.

License

This app is open-sourced software licensed under the MIT license.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScriptcronnodenuxt-modulenuxt3

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架