Send a queue job
Enqueue payloads with runQueue and the common delivery patterns.
Use runQueue() to enqueue one job by queue name.
Send the common payload-first form
The simplest form is runQueue(name, payload).
import { runQueue } from '@vitehub/queue'
await runQueue('welcome-email', {
email: 'ava@example.com',
})
Use this form when you only need to pass the payload and let the provider choose the rest.
Send with delivery options
Switch to an input object when you need options such as a custom job ID or delayed delivery.
import { runQueue } from '@vitehub/queue'
await runQueue('welcome-email', {
id: 'welcome-1',
payload: {
email: 'ava@example.com',
},
delaySeconds: 10,
})
Send from an API route
server/api/queues/welcome.post.ts
import { readBody } from 'h3'
import { runQueue } from '@vitehub/queue'
export default defineEventHandler(async (event) => {
const { email } = await readBody(event)
return runQueue('welcome-email', {
email,
})
})
Know what stays stable
These parts stay the same across providers:
- the queue name
- the
runQueue()call site - the payload shape you pass in
Provider-specific delivery options vary. Use the provider pages when you need details such as Cloudflare delays, Vercel callback behavior, or Upstash QStash destinations.