Hono guide · Node.js SDK

Hono rate limiting,on every runtime Hono runs.

One app.use() validates the caller’s key, charges their credits, and applies their plan’s limit — whether you deploy to Bun, Deno, Node, or Workers.

  • Keys issued per customer
  • Credits that refill
  • Limits per plan, not per process

Official SDKs with drop-in middleware for the stack you already run

  • Python
  • Node.js
  • Go
  • Rust
  • PHP
  • .NET
  • Java
API requests validated
100M+
Average key validation
<5ms
Average analytics ingest
<5ms
Check and log, end to end
<10ms

The usual Hono rate limiter counts requests. It doesn’t know your customers.

hono-rate-limiter follows express-rate-limit’s shape: a window, a limit, and a keyGenerator — with separate stores for Redis, Durable Objects, or KV on Workers.

With hono-rate-limitertoday
// index.ts — with hono-rate-limiterimport { rateLimiter } from "hono-rate-limiter";

app.use(
  rateLimiter({
    windowMs: 15 * 60 * 1000,
    limit: 100,
    standardHeaders: "draft-6",
    keyGenerator: (c) => c.req.header("x-api-key") ?? "",
  }),
);
  • A store per runtime — memory, Redis, KV, or Durable Objects — each with its own consistency rules
  • The header value is counted, not checked
  • No API keys: issuing, hashing, scoping, and revoking them is still yours to build
  • No credit balance: a request can’t cost 5 on one route and 1 on another, or refill each month
  • One limit for everyone — no per-plan limits for Free, Pro, and Enterprise customers
  • No per-customer usage log to answer “why was I blocked?” or bill against
With ReqKey in Honoone middleware
  • API keys issued per customer, prefixed, hashed, and revocable from the dashboard
  • A credit balance per customer — price each route, refill every hour, day, week, or month
  • Rate limits set per plan, shared by all of a customer’s keys, from 1 second to 24 hours
  • The same count on every worker, instance, and region — no Redis to run
  • Over the limit? A 429 with Retry-After, and no credits charged
  • Every request logged per customer — status, latency, endpoint — in under 5ms
Your handler reads the verdict with context.get("reqkey"). See the code

Hono in three steps, one of them code.

ReqKey runs inside your API, not in front of it. Your server asks one question per request and gets an answer in under 5ms.

  1. 1

    Install the SDK

    npm install reqkey hono

  2. 2

    Set your project key

    Copy it from the dashboard into REQKEY_PROJECT_KEY. It stays on your server.

  3. 3

    Add the Hono middleware

    Every request is checked, charged, and logged before your handler runs.

index.tsnpm install reqkey hono
import { Hono } from "hono";
import { reqkey, type ReqKeyHonoEnv } from "reqkey/hono";
 
const app = new Hono<ReqKeyHonoEnv>();
 
app.use(
reqkey({
projectKey: process.env.REQKEY_PROJECT_KEY,
apiId: "api_payments",
mode: "both",
keyName: "x-startup-key",
excludePaths: ["/health"],
}),
);
 
app.post("/payments", (context) => {
const decision = context.get("reqkey");
return context.json({ created: true, creditsRemaining: decision?.creditsRemaining }, 201);
});
 
export default app; // Bun / Deno / Workers — or serve(app) via @hono/node-server
Also in Node.js: Express, Next.js, NestJS, Fastify, KoaFull Node.js reference

Every request gets one of these answers

  • 200Valid key, credits charged — your handler runs
  • 402Out of credits
  • 403Key disabled, or not allowed on this API
  • 429Over the rate limit — no credits charged

Where ReqKey sits

Your customer
Your APIReqKey, under 5ms
Your handler

Responses go straight back to your customer. ReqKey sees the key check and the log line, nothing else.

Credits

Charge each route what it costs you.

A lookup can cost 1 credit and a render 5, from the same balance. Excluded paths are never validated, charged, or recorded. In Node.js:

Per-route credits · Node.js
// Exact paths or trailing-* prefixes: never validated, charged, or recorded
excludePaths: ["/health", "/openapi.json", "/docs/*", "/cron/*"]
 
// Or decide per request with a sync or async resolver
shouldProtect: ({ path }) => path.startsWith("/api/")
 
// Charge different endpoints differently (non-negative integers)
credits: ({ method, path }) => {
if (method === "POST" && path === "/images") return 5;
if (path.startsWith("/reports/")) return 2;
return 1;
}

Rate limits

Set limits on plans, not in code.

Your Hono code never hard-codes a number. Each plan carries its credits, refill, and rate limit; moving a customer to Pro changes all three with no deploy.

PlanCreditsRate limit
Free1,000 / month5 req / s
Pro50,000 / month50 req / s
Scale1,000,000 / month500 req / s
429Over the limit, a call is answered with Retry-After and costs nothing — no credits and no quota.

Example plans. You name them and pick the numbers.

Notes for Hono teams hit in production.

Typed context

new Hono<ReqKeyHonoEnv>() types context.get("reqkey"), so the verdict is fully typed in every handler.

Edge and serverless

Nothing is held in isolate memory. A customer calling two edge locations draws on one balance.

Same code on every runtime

Export the app for Bun, Deno, and Workers, or serve it with @hono/node-server — the middleware doesn’t change.

Hono rate limiting: the questions teams ask.

Something else? Ask the team or read the docs.

  • The Hono adapter is built for Bun, Deno, and edge runtimes as well as Node. Provide REQKEY_PROJECT_KEY from your runtime’s environment or secrets.

  • No. Counts and balances are kept by ReqKey, so there is no storage binding to add for rate limiting.

  • On their plan or on the customer (consumer) in ReqKey — a number of requests per window from 1 second to 24 hours, shared by all of that customer’s keys. Your Hono code never hard-codes a limit, so upgrading a customer is a dashboard change, not a deploy.

  • A check averages under 5ms. ReqKey runs inside your app as middleware, not as a gateway in front of it, so responses go straight back to your customer.

  • You choose: fail closed and answer 503, or fail open and let requests through. Invalid keys are denied either way, and a validation is never retried, so no one is charged twice.

Ship API keys in Honoin five minutes.

Free for your first 5 million requests every month. No card, no gateway, no rewrite.