Skip to content

Data transforms

These examples use real payload-carrying workloads on purpose. Primitive-only tasks are often near-instant, which hides coordination and transfer costs. Payload transforms are closer to production traffic, so the host-vs-worker comparisons are more honest.

Treat the benchmark blocks in this section as supporting material, not the main event. Most pages are now organized around the runnable example first, with a benchmark command attached if you want to measure the same pattern on your machine. If you want one page that keeps the full performance discussion, start with Hono server routes.

If you’re validating incoming data — API payloads, form submissions, webhook bodies — start with Schema validation. It’s the simplest validation pattern and uses Zod, which you’re probably already familiar with.

If you’re doing auth work — token verification, renewal, signature checking — JWT revalidation shows how to offload HMAC crypto to workers using built-in Web Crypto (no external JWT library).

If you’re hashing passwordsSalt hashing is the heaviest per-call example. PBKDF2 is intentionally slow, making it the ideal candidate for offloading.

If you’re calling an LLMPrompt token budgeting trims prompts to fit a token budget. The budgeting itself is model-agnostic.

If you’re rendering HTMLReact SSR for basic server rendering, React SSR compression to also test Brotli placement, or Markdown to HTML for a simpler pipeline without React.

If you handle file uploadsImage processing API offloads resize, thumbnail, and watermark operations to workers using sharp. It’s the binary payload counterpart to the Hono SSR example.

If you want the full pictureHono server routes is a real HTTP server that combines SSR, JWT, and health checks. It’s the closest to a production setup.

  • Each includes a host-only baseline so performance comparisons are apples-to-apples.
  • Worker tasks return compact results (counts, compressed buffers, status flags) — not large raw payloads.
  • The same code runs in both host and worker mode, so you can compare behavior without changing logic.