FRAMEWORK Cloudflare Workers, Bun, Deno, Node.js

API Protection for Hono

Lightweight middleware for Hono that works on Cloudflare Workers, Bun, and Deno. AI token rate limiting and revenue protection at the edge.

How do I protect a Hono API on Cloudflare Workers?

Install @holdify/core, create a client with your project key, and add middleware to verify API keys. Works on Workers, Bun, and Deno with <50ms verification. AI token budgets and dollar limits included.

npm install @holdify/core
Hono Integration
typescript
// Using @holdify/core with Hono
import { Hono } from 'hono';
import { createClient } from '@holdify/core';

const app = new Hono();
const holdify = createClient({
  apiKey: process.env.HOLDIFY_PROJECT_KEY
});

// Middleware for all /api routes
app.use('/api/*', async (c, next) => {
  const key = c.req.header('x-api-key');
  if (!key) {
    return c.json({ error: 'Missing API key' }, 401);
  }

  const result = await holdify.verify(key);
  if (!result.valid) {
    return c.json({ error: 'Invalid API key' }, 401);
  }
  if (result.remaining <= 0) {
    return c.json({ error: 'Rate limit exceeded' }, 429);
  }

  c.set('holdify', result);
  await next();
});

export default app;

Why Holdify for Hono

AI Gateway Ready

Token-aware rate limiting for AI proxies. Protect revenue from runaway API costs.

Cloudflare Workers Native

Built for edge environments. Works seamlessly on Cloudflare Workers with zero dependencies.

Bun & Deno Support

Runtime-agnostic core SDK works on Bun, Deno, and Node.js.

Minimal Overhead

Tiny bundle size (~5KB) with no runtime dependencies.

Features

Universal Runtime

Same code works on Workers, Bun, Deno, and Node.js.

Hono Middleware Pattern

Follows Hono's middleware conventions for clean integration.

Context Storage

Store verification results in Hono context for route handlers.

Edge-Optimized

Designed for edge compute with minimal cold start impact.

Frequently Asked Questions

Does Holdify work for AI API proxies?

Yes. Holdify is designed for AI-first apps. Track token usage per customer and enforce dollar-based spending caps at the edge.

Is there a dedicated Hono SDK?

Use @holdify/core which is runtime-agnostic and works perfectly with Hono's middleware pattern.

Does it work on Cloudflare Workers free tier?

Yes. The SDK is optimized for Workers' CPU time limits and works on free tier.

What about Deno Deploy?

The core SDK works on Deno Deploy. Import via npm: specifier or use the Deno-native bundle.

Start Protecting Your Hono API

Get started in under 10 minutes. Free tier includes 150K requests/month.

Get Started with Hono