Skip to content

Installation

Stoma requires Hono v4.0.0 or later as a peer dependency. Install both together:

Terminal window
npm install @homegrower-club/stoma hono
PackageVersionPurpose
hono>=4.0.0Required peer dependency. Provides the router, context, and middleware system.
zod>=3.0.0Optional. Enables config schema validation at construction time.

If you want Zod-based config validation:

Terminal window
npm install zod

Stoma is written in TypeScript and exports raw .ts source files directly — there is no build step. Your bundler (Vite, esbuild, wrangler) compiles the TypeScript at build time alongside your own code.

Your tsconfig.json should use these settings at minimum:

{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "bundler",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true
}
}

Key requirements:

  • target: "ES2022" or later. Stoma uses structuredClone, AbortSignal.timeout, crypto.subtle, and other modern APIs. These are available natively in Cloudflare Workers, Deno, Bun, and Node.js 20+.
  • moduleResolution: "bundler". Required for subpath exports (@homegrower-club/stoma/policies, @homegrower-club/stoma/config) to resolve correctly.
  • strict: true. Recommended. Stoma’s types are authored with strict mode enabled.

The package exposes five entry points:

Import pathContents
@homegrower-club/stomaMain entry: createGateway, all built-in policies, SDK helpers, all types
@homegrower-club/stoma/policiesPolicy factory functions, SDK helpers, and policy types only
@homegrower-club/stoma/configConfig type re-exports + Zod validation schemas (validateConfig, safeValidateConfig, GatewayConfigSchema)
@homegrower-club/stoma/sdkPolicy SDK: definePolicy(), createPolicyTestHarness(), Priority constants, resolveConfig, policyDebug, withSkip
@homegrower-club/stoma/adaptersCloudflare-specific adapters (KV, Durable Objects)

For most use cases, import everything from the main entry point:

import { createGateway, jwtAuth, rateLimit, cors } from "@homegrower-club/stoma";

For custom policy development, import the SDK directly:

import { definePolicy, Priority, createPolicyTestHarness } from "@homegrower-club/stoma/sdk";

Stoma runs on any runtime Hono supports. The core library has no runtime-specific dependencies. Additional setup depends on where you deploy.

Install the Workers type definitions as a dev dependency:

Terminal window
npm install -D @cloudflare/workers-types

Add them to your tsconfig.json:

{
"compilerOptions": {
"types": ["@cloudflare/workers-types"]
}
}

This enables typed access to c.env bindings (secrets, Service Bindings, KV namespaces). The @homegrower-club/stoma/adapters subpath export provides Cloudflare-specific stores for rate limiting (KV, Durable Objects) and circuit breakers.

Install the Hono Node.js adapter:

Terminal window
npm install @hono/node-server

Then serve the gateway app:

import { serve } from "@hono/node-server";
serve({ fetch: gateway.app.fetch, port: 3000 });

No additional dependencies are needed. Export or serve the gateway.app directly using the runtime’s native APIs. See the Quick Start for examples.

With the package installed, proceed to the Quick Start to define your first gateway.