npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@engblock/microfrontend-hono-gateway

v0.0.2

Published

[![npm version](https://badge.fury.io/js/%40engblock%2Fhono-gateway-core.svg)](https://badge.fury.io/js/%40engblock%2Fhono-gateway-core) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Readme

Hono Gateway Core (@engblock/hono-gateway-core)

npm version License: MIT

Core library for building flexible, type-safe micro-frontend or micro-service gateways using Hono. This library provides the foundational components to route incoming requests based on URL prefixes to different handlers, supporting both direct function calls (monorepo style) and HTTP forwarding (e.g., Cloudflare Workers Service Bindings).

Overview

In modern web architectures, it's common to split applications into smaller, independently deployable units (micro-frontends or micro-services). A gateway acts as the single entry point, routing requests to the appropriate downstream service or rendering module.

hono-gateway-core simplifies the creation of such gateways within the Hono framework by providing:

  1. A Gateway Factory (createGateway): Sets up a Hono application with core routing logic.
  2. An Abstraction Layer (MicroAppHandler): Decouples the gateway from the specific mechanism used to handle the request (direct call vs. HTTP fetch).
  3. Concrete Handler Implementations:
    • DirectCallHandler: For invoking local ssr functions directly (ideal for monorepos).
    • HttpFetchHandler: For forwarding requests to other HTTP endpoints or Cloudflare Worker Service Bindings.
  4. Type Safety: Leverages TypeScript for robust development.

Core Concepts

  • Gateway: The main Hono application instance created by createGateway. It intercepts requests matching patterns like /:appName/* and uses the configuration to find the correct handler.
  • MicroAppHandler: An interface defining the contract for handling a request delegated by the gateway. The key method is handle(c: Context): Promise<Response>, which must return a complete Response object.
  • DirectCallHandler: An implementation of MicroAppHandler that takes a module conforming to the DirectRenderApp interface (having an ssr(c: Context): Promise<string> | string method). It calls the ssr method and wraps the resulting HTML string in a Response.
  • HttpFetchHandler: An implementation of MicroAppHandler that forwards the incoming request to another HTTP service. It can be configured to use Cloudflare Worker Service Bindings (type: 'cf_binding') or a standard base URL (type: 'url'). It returns the Response received from the downstream service.
  • HandlerConfigFactory: A function (c: Context<GatewayEnv>) => HandlerConfig provided to createGateway. It's responsible for creating the mapping between URL prefixes (e.g., "profile") and their corresponding MicroAppHandler instances. Crucially, it receives the Hono Context (c), allowing access to environment variables (c.env) needed for configuring handlers (like HttpFetchHandler with service bindings).

Features

  • Flexible Delegation: Supports both direct function invocation and HTTP forwarding out-of-the-box.
  • Type-Safe: Built with TypeScript, providing strong typing for configuration and context.
  • Extensible: Easily create custom MicroAppHandler implementations for other delegation strategies.
  • Hono Integration: Built on top of the fast and lightweight Hono framework.
  • Environment-Aware Configuration: Access environment variables/bindings within the configuration factory.
  • Testability: The handler abstraction makes individual routing strategies easier to test in isolation.

Installation

# Using npm
npm install @engblock/hono-gateway-core hono

# Using yarn
yarn add @engblock/hono-gateway-core hono

# Using pnpm
pnpm add @engblock/hono-gateway-core hono