A minimal Nitro example showing how to send messages to Vercel Queues from a Hono server entry, and process them via the vercel:queue hook registered from a Nitro plugin.
orders, notifications) under vercel.queues.triggers, and registers queue-handler.ts as a Nitro plugin.POST /api/enqueue. It accepts { topic, message } and calls send(topic, message) from @vercel/queue.vercel:queue and dispatches incoming messages to a per-topic handler via metadata.topicName.pnpm install
pnpm dev
Note: vercel:queue only fires when deployed to Vercel. Locally you can still hit POST /api/enqueue, but send() requires Vercel credentials and the consumer function won’t run.
pnpm build
npx vercel deploy --prebuilt
queue-handler.ts is a Nitro plugin that registers a single vercel:queue hook and looks up a handler by metadata.topicName:
export default definePlugin((nitro) => {
nitro.hooks.hook("vercel:queue", async ({ message, metadata }) => {
const handler = handlers[metadata.topicName];
await handler?.(message, metadata);
});
});
Add a new topic by adding an entry to vercel.queues.triggers in nitro.config.ts and a matching key in the handlers map.