npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

nuxt-simple-bullmq

v1.8.4

Published

Simple Nuxt module for background tasks using bullmq

Readme

Nuxt Simple BullMQ Module

Build npm version npm downloads License Nuxt

Simple Nuxt 3 module using BullMQ and Redis for doing amazing things.

Features

  • ⛰  Foo
  • 🚠  Bar
  • 🌲  Baz

Quick Setup

Install the module in your Nuxt application with one command:

npx nuxi module add nuxt-simple-bullmq

NOTE: This is only tested with NodeJS 21 (not cloudflare/vercel etc) and Nuxt 4 with experimental features (see test workflows/files for more)

Add the config

// nuxt.config.ts
{
  runtimeConfig: {
    redis: {
      url: 'redis://localhost:6379'
    }
  },
  bullMq: {
    // Where to load defined workers from (defineWorker files)
    // this is optional, and will default to [ '<serverDir>/workers' ]
    workerDirs: [ '/workers' ], // base path will be your "serverDir" e.g ./server/some-path
  }
}

or use NUXT_REDIS_URL in your $environment

That's it! You can now use BullMQ in your Nuxt app ✨

Usage

Workers

A worker lives in its own file and each worker is registered as a separate nitro plugin.

// ./server/workers/default,ts
export default defineWorker('default', {
  async sendWelcomeEmail({job, logger, lockId}) {
    logger.info(`Sending welcome email to ${job.data.email}`)
  },

  // magic catch-all event handler (for uncaught events):
  catchAll({job, logger}) {
    logger.debug(`Uncaught event: ${job.name}!`, job.data)
  }
}, {
  //optional: default //comment
  concurrency: 1, //how many of each worker to run
});

Jobs

Jobs are handled through callbacks, they can be in their own files, defined directly on the worker etc.

Note: There is no typing for dispatching jobs - yet :/ One solution can be to use a constant mapping e.g const JobNames = {someKey: 'someValue'}

// ./server/jobs/sendWelcomeEmail.ts
export default defineJobHandler(({job, logger}) => {
  logger.debug(job.name, job.data)
})

Validated job handlers

// ./server/jobs/sendWelcomeEmail.ts
import {z} from 'zod';

export default defineValidatedJobHandler(
  z.object({userId: z.string()}),
  async ({data, job, logger}) => {
    // data contains the validated payload from the schema
    // data is also typed: {userId:string}
  },
);

Note: Validates input before processing the job

Delaying jobs

// ./server/jobs/onboarding/sendTipsAndTricks.ts
import {z} from 'zod'
import {DelayedError} from 'bullmq';

export default defineValidatedJobHandler(
  z.object({userId: z.string().uuid()}),
  async ({data: {userId}, job, logger, lockId}) => {
    const DELAY_MS = 1_800_000 // 30 minutes

    // do some checks...
    if (!await userHasVerifierEmail() && !hasBeenMoreThan24HoursSinceSignUp()) {
      logger.info('Preconditions not met, delaying job...')
      await job.moveToDelayed(Date.now() + DELAY_MS, lockId)
      throw new DelayedError();
    }

    logger.info(`Sending Tips & Tricks to user ${userId}`)
  },
)

Dispatching Jobs

// ./server/route/dispatch.ts
import {dispatchJob} from '#imports'

export default defineEventHandler(async event => {
  await dispatchJob(
    'sendWelcomeEmail', 
    {userId: 'abc'},
    // Optional:
    {queueName: 'default', attempts: 1, backoff: {strategy: 'exponential', } },
  )
})

Validated job dispatch

// ./server/route/typed-dispatch.ts
import {dispatchValidatedJob} from '#imports'

export default defineEventHandler(async event => {
  await dispatchValidatedJob(
    'sendWelcomeEmail',
    z.object({userId: z.string()}),
    {userId: 'abc'},
    {queueName: 'default'},
  )
})

This will validate the input before emitting the job to redis

Additional options

You can pass the same options that are passed as the third argument when calling emit to dispatchJob and dispatchValidatedJob as well.

// ./server/route/name.ts
import {useQueue} from '#imports'

//e.g using H3 event handlers
export default defineEventHandler(async event => {
  const queue = useQueue('default');
  await queue.emit('sendWelcomeEmail', {userId: 'some-string'}, {
    //Optionals (with their defaults)
    queueName: 'default',

    //optionals without defaults
    deduplicationId: 'some-string', // can be anything, defaults to the event name.
    ttl: 500, // when the deduplication should expire
    delay: 500, // a delay to when this will run (good for notifications)
  })

  //validate schema first:
  await queue.emit('sendWelcomeEmail', {userId: 'some-string'}, {
    schema: z.object({userId: z.string()}), // optional
    //... other options 
  })
})

Roadmap

  • [X] Add handlers
  • [X] Worker per plugin
  • [X] Validation dispatch/handler
  • [ ] File based listeners (Laravel style with a "dispatch" method)
  • [ ] Flow producers
  • [ ] Different lib/platform (e.g Vercel/Cloudflare)

Contribution

# Install dependencies
npm install

# Generate type stubs
npm run dev:prepare

# run redis via docker (add -s to detach and continue using the terminal for other stuff)
docker compose -f ./playground/compose.yml up [-d]

# to stop docker stuff:
docker compose -f ./playground/compose.yml down

# Develop with the playground
npm run dev

# Build the playground
npm run dev:build

# Run ESLint
npm run lint

# Run Vitest
npm run test
npm run test:watch

# Release new version
npm run release