No Redis Required: Zero-Config Job Queue for Bun
Source: Dev.to
Using Bunqueue without Redis
import { Queue, Worker } from 'bunqueue/client';
const queue = new Queue('tasks', { embedded: true });
await queue.add('process', { userId: 123 });
new Worker('tasks', async (job) => {
return { done: true };
}, { embedded: true });
That’s the entire infrastructure—no Redis, no Docker, no connection strings, no separate server process.
Embedded Mode
When embedded: true is set, Bunqueue creates a SQLite database in your project and manages everything in‑process:
Your App Process
├── Your Code
├── Queue (in‑memory priority queues)
├── Worker (processes jobs)
└── SQLite (./data/bunq.db)
One process. One file. Done.
Example: Email Queue
import { Queue, Worker } from 'bunqueue/client';
interface EmailJob {
to: string;
template: string;
data: Record;
}
const emails = new Queue('emails', { embedded: true });
// Add jobs from your API routes
await emails.add(
'welcome',
{
to: 'user@example.com',
template: 'welcome',
data: { name: 'John' },
},
{
attempts: 3,
backoff: 5000,
priority: 10,
}
);
// Process in the same app
const worker = new Worker(
'emails',
async (job) => {
await job.updateProgress(10, 'Loading template');
const html = await renderTemplate(job.data.template, job.data.data);
await job.updateProgress(50, 'Sending');
await sendEmail(job.data.to, html);
return { sent: true };
},
{
embedded: true,
concurrency: 5,
}
);
worker.on('failed', (job, err) => {
console.error(`Email to ${job.data.to} failed: ${err.message}`);
});
Installation
bun add bunqueue