14 · Integrations
Cloudflare Queue — async work
Enqueue work over HTTP, consume in the same Worker via a queue() handler.
Code
cloudflare-queue.js
import { WebApp } from class="tk-str">39;@hyperbridge/forge/server39;; const app = new WebApp(); app.post(class="tk-str">39;/enqueue39;, async (c) => { await c.env.MY_QUEUE.send(await c.req.json()); return c.json({ ok: true }); }); export default { fetch: app.fetch, async queue(batch, env) { for (const msg of batch.messages) { console.log(class="tk-str">39;processing39;, msg.body); msg.ack(); } }, };
How it works
Cloudflare's queue() handler runs whenever Workers picks up a batch. Acknowledge each message individually for granular retry control.
fetch: app.fetch wires the WebApp into the Worker's HTTP entry; queue sits alongside as a sibling handler.
For Node-side queues without Cloudflare, use forge/queue directly — same API, runs in-process.
Try it
Quickstart
wrangler dev → POST /enqueue → tail logs for processing
Related modules
This is HBForge's port of Hono's example. Read the original at hono.dev/examples/cloudflare-queue.