Skip to main content
This guide shows you how to integrate BosonMail into Hono applications running on Node.js and on Cloudflare Workers. You will wire environment variables, validate requests, send emails, check status, and handle file uploads using Hono’s built-in helpers.
The BosonMail SDK uses only web-standard globals: fetch, FormData, Blob, and AbortController. It has no Node-specific imports, so it is expected to work in any runtime that provides these globals. BosonWare has not officially verified Cloudflare Workers support, so test before production.

Prerequisites

  • A Hono project on Node.js or Cloudflare Workers
  • A BosonMail API key
  • Node.js 18 or later (for the Node.js section)

Hono on Node.js

Install dependencies

Create the application

Use process.env for the API key and mount routes for sending and status checks.
src/index.ts
c.req.parseBody() returns File objects when the request is multipart/form-data. You can pass these directly to the SDK because File extends Blob.

Hono on Cloudflare Workers

Environment bindings

On Workers, store the API key as a secret binding and access it via c.env.
src/index.ts

Secrets and local development

Upload your secret to Workers:
For local development, create .dev.vars:
.dev.vars
Cloudflare Workers CPU and wall-clock limits apply. Do not implement status polling loops inside a request handler. If you need periodic reconciliation, use a Cron Trigger or a queue consumer instead.

Optional: validation with Zod

You can add @hono/zod-validator for schema-based validation if you want stricter type checking.

Error response mapping

Return consistent HTTP status codes across both runtimes.

Sending emails

SDK reference for sendEmail and its options.

Email status

How to check delivery status with getEmailStatus.

Production best practices

Key management, retries, logging, and monitoring guidance.

Attachments

SDK reference for sending file attachments.