Quirrel is the Task Queueing Solution for Next.js X Vercel.
Check out Getting Started Guide or the Quirrel Tutorial to get the full picture.
npm install @quirrel/next
- Create a new API Route and export a Quirrel Queue:
// pages/api/emailQueue.js
import { Queue } from "@quirrel/next"
export default Queue("emailQueue", async (job) => {
await dispatchEmail(job.recipient, job.subject, ...);
})
- Import & use from another file to enqueue jobs:
// pages/api/signup.js
...
import emailQueue from "./emailQueue"
export default async (req, res) => {
// create user ...
await emailQueue.enqueue({
recipient: user.email,
subject: "Welcome to Quirrel!",
...
})
}
When calling .enqueue
, a request to api.quirrel.dev is made. It contains an endpoint to call (in the example above, that'd be /api/emailQueue
) and a timestamp of when it should be called.
The Quirrel API will then call the corresponding endpoint on time.
Quirrel is currently in development. I will post updates on Twitter.