Quick Start
Get started with DataQueue
In this docs, we'll use a Next.js with App Router project which is deployed to Vercel as an example.
Next.js Shortcut
If you're using Next.js, you can scaffold everything — API routes, a job queue singleton, a cron script, and all dependencies — with a single command:
npx dataqueue-cli initThe command auto-detects your project structure (App Router vs Pages Router, src/ directory vs root) and creates all the files you need. See the init CLI reference for full details.
If you prefer to set things up manually, follow the steps below.
PostgreSQL Backend
- Run migrations before deploying your app
- Define job handlers
- Initialize the job queue
- Add a job
- Create three API routes to process jobs, reclaim stuck jobs, and cleanup old jobs
- Call those API routes periodically via a cron service (like Vercel cron) or a small script like this one during development.
Redis Backend
- Install
ioredis - Define job handlers
- Initialize the job queue with Redis config
- Add a job
- Create three API routes to process jobs, reclaim stuck jobs, and cleanup old jobs
- Call those API routes periodically via a cron service (like Vercel cron) or a small script like this one during development.
The Redis backend requires no database migrations. Just install ioredis,
configure the connection, and you're ready to go.
Long-Running Server
If you're running a persistent server (Express, Fastify, plain Node.js, etc.) instead of a serverless environment, the setup is slightly different:
- Run migrations (PostgreSQL) or install
ioredis(Redis) - Define job handlers
- Initialize the job queue
- Start the processor in the background with
startInBackground() - Start the background supervisor with
createSupervisor()to automate maintenance (reclaim stuck jobs, cleanup old data) - Handle
SIGTERM/SIGINTfor graceful shutdown withstopAndDrain()
See Long-Running Server for a complete walkthrough and full example.