Skip to content
Docs

Process agent events and background work reliably
Beta

Send messages for agent events and background work to durable topics, then process them with independent consumers, automatic retries, and at-least-once delivery.
send-message.ts
import { send } from '@vercel/queue';
 
const { messageId } = await send('orders', {
  orderId: 'order_123',
  status: 'ready',
});
 
console.log(messageId);
app/api/queues/fulfill-order/route.ts
import { handleCallback } from '@vercel/queue';
 
export const POST = handleCallback(async (order, metadata) => {
  console.log('Fulfilling order', metadata.messageId, order);
});
vercel.json
{
  "functions": {
    "app/api/queues/fulfill-order/route.ts": {
      "experimentalTriggers": [{ "type": "queue/v2beta", "topic": "orders" }]
    }
  }
}

Vercel Queues are available in Beta on all plans

Each Vercel Queues topic is a durable, append-only log that retains messages until they expire. Messages fan out to every consumer group subscribed to the topic, and new consumer groups can join at any time to replay non-expired history.

Producer Topic Producer Consumer Group A(email notifications) Consumer Group B(analytics pipeline) Consumer Group C(audit log)

Vercel Queues is useful when you need to:

  • Defer expensive work: Offload tasks like sending emails, generating PDFs, or calling external APIs so your response returns fast.
  • Absorb traffic spikes: Buffer incoming requests and process them at a controlled rate.
  • Retry failed work: Redeliver messages after a consumer crashes or a deployment rolls out, until the handler succeeds or the message expires.
  • Schedule tasks: Delay message delivery by up to the retention period.
  • Deduplicate publishes: Use idempotency keys to drop repeated publishes during the message's retention period.
  • Isolate consumers: Process the same messages in multiple independent pipelines without interference.
  • Replay agent activity: Give each viewer an independent replay of an agent's file edits, terminal commands, and tool calls.

Vercel Queues is the lower-level primitive that powers Vercel Workflows. Workflows provides a higher-level SDK with durable steps, sleep, and hooks that makes building multi-step applications more ergonomic. If you need direct control over message publishing, consumption, and routing, use the Queues SDK directly. If you're building stateful multi-step workflows, start with Workflows.

  • Durable delivery: Persist messages with retries and visibility timeouts for reliable processing.
  • Fan-out consumers: Send one message stream to multiple independent consumer groups without coordination.
  • Push and poll modes: Process on Vercel with push callbacks or run your own workers.
  • Automatic scaling: Scale producers and consumers without managing partitions or throughput capacity.
  • SDK and API: Publish and consume with the SDK or HTTP API.
  • Observability: Monitor queue throughput, message age, and consumer performance.

Was this helpful?

supported.