This site is not affiliated with or endorsed by Vercel, Inc. Read the docs, then deploy or run each experiment yourself.
Platform

Queues Lab

Publish to a durable Vercel Queues topic and process messages with a private push consumer.

Run this experiment yourself

Demos are not embedded on this site. Deploy a standalone copy on Vercel or run the experiment app locally.

Local development

cd apps/experiments/queues-lab
pnpm install
pnpm dev

Then open http://localhost:3010.

This is an experimental demo. Use it as a starting point for your own projects.

The Queues Lab demonstrates Vercel Queues (public beta): durable topics, fan-out consumer groups, and at-least-once delivery with retries. Producers call send() from @vercel/queue. A private consumer uses handleCallback and is registered with experimentalTriggers type queue/v2beta in vercel.json.

Features

  • Live publish. POST /api/queues/publish with mode: "live" calls send('experiments-orders', payload).
  • Private fulfill consumer. app/api/queues/fulfill/route.ts records processed messages when Queues invokes it.
  • Simulator mode. In-memory fan-out across fulfillment and analytics groups, plus idempotency-key dedupe, for local learning without OIDC.
  • Honest errors. Missing OIDC returns 503 with setup requirements instead of inventing message ids.

API Reference

POST /api/queues/publish

Prop

Type

GET /api/queues/publish

Returns the topic name, recent processed entries, and simulator backlog.

Consumer (POST fulfill)

Configured only via Queues push - not a public webhook:

apps/experiments/queues-lab/vercel.json
{
  "functions": {
    "app/api/queues/fulfill/route.ts": {
      "experimentalTriggers": [
        { "type": "queue/v2beta", "topic": "experiments-orders" }
      ]
    }
  }
}

Implementation Details

Producer (live path):

apps/experiments/queues-lab/app/api/queues/publish/route.ts
const { send } = await import('@vercel/queue');
const result = await send(QUEUE_TOPIC, payload, idempotencyKey
  ? { idempotencyKey }
  : undefined);

Consumer:

apps/experiments/queues-lab/app/api/queues/fulfill/route.ts
export const POST = handleCallback(async (order, metadata) => {
  recordProcessed({
    messageId: metadata.messageId,
    orderId: order.orderId ?? 'unknown',
    receivedAt: new Date().toISOString(),
    source: 'queue-callback',
  });
});

TopicSimulator in logic.ts models fan-out and retry/expire behaviour for the educational path.

Use Cases

  • Offload email, PDF, or provider calls after a fast HTTP response
  • Absorb traffic spikes with buffered processing
  • Fan out one event stream to independent pipelines (analytics vs fulfillment)

Limitations

  • Queues is in public beta; APIs and limits can change.
  • Live mode needs OIDC (vercel link + vercel env pull) or a Vercel deployment.
  • The in-memory log resets on cold start - it is not durable storage.
  • Prefer Workflows when you need multi-step durable orchestration with sleep/hooks.

Use in your project

  1. pnpm add @vercel/queue
  2. Publish with send(topic, payload)
  3. Add a handleCallback route and experimentalTriggers in vercel.json
  4. Keep handlers idempotent

Deployment

Deploy on Vercel

After deploy, publish with the UI (live mode) or curl, then check Observability - Queues and the recent-processed list in the demo.

Local Development

cd apps/experiments/queues-lab
pnpm install
vercel link && vercel env pull
pnpm dev

Use simulator mode without OIDC. Unit tests:

pnpm vitest run ../experiments/queues-lab

Configuration

SetupRequiredNotes
OIDC via vercel env pullLive publish/consumeAutomatic on Vercel
vercel.json queue triggerConsumerAlready included

Vercel / Next.js Features Used

Next Steps

On this page