---
title: "Presets and Builds"
description: "The presets and builds system provides specialized distribution bundles, entry points, and routing optimizations tailored for different runtime performance characteristics and footprint constraints..."
last_updated: "2026-10-12T08:14:12.710392+00:00"
canonical_url: "https://www.doc0.dev/docs/552ca36e-f67e-41c3-a07a-def9bd9551b0/core-engine/presets-and-builds"
---


## Overview

The presets and builds system provides specialized distribution bundles, entry points, and routing optimizations tailored for different runtime performance characteristics and footprint constraints. Hono delivers standard functionality through its core router composition while offering lightweight distribution presets such as `[[Application Core]]` routing alternatives, package export mappings across `package.json` and `jsr.json`, and automated bundle size auditing harnesses [src/preset/quick.ts:1-23, [package.json:37-67, [src/preset/tiny.ts:1-19, [jsr.json:8-106, perf-measures/bundle-check/scripts/check-bundle-size.ts:1-50. Sources: src/preset/quick.ts:1-23, package.json:37-67, src/preset/tiny.ts:1-19, jsr.json:8-106, perf-measures/bundle-check/scripts/check-bundle-size.ts:1-50

## Preset Architecture and Entry Points

### Specialized Distribution Entry Points

Hono exposes multiple public distribution entry points designed for different runtime environments, bundle size thresholds, and routing performance profiles. The standard entry point at `.` resolves to the main package distribution, while specialized preset modules such as `[[Application Core]]` routing bundles target restricted environments package.json:37-67, jsr.json:8-106.

Hono organizes its distribution bundles across standard CommonJS, ESM, and type definition outputs defined in `package.json` and registry manifests in `jsr.json`. Consumers can import specialized presets directly from subpaths such as `./quick` and `./tiny` to optimize their application build output package.json:37-67, jsr.json:8-106.

| Export Subpath | Type Definitions | ESM Output | CommonJS Output | Preset Purpose |
| -------------- | ---------------- | ---------- | --------------- | -------------- |
| `.` | `./dist/types/index.d.ts` | `./dist/index.js` | `./dist/cjs/index.js` | Standard multi-router entry point |
| `./quick` | `./dist/types/preset/quick.d.ts` | `./dist/preset/quick.js` | `./dist/cjs/preset/quick.js` | `[[Application Core]]` with `SmartRouter` (Linear + Trie) |
| `./tiny` | `./dist/types/preset/tiny.d.ts` | `./dist/preset/tiny.js` | `./dist/cjs/preset/tiny.js` | `[[Application Core]]` with lightweight `PatternRouter` |


### Architectural Trade-Offs

The standard package entry point imports from `./hono`, allowing developers to leverage comprehensive feature sets across middlewares and helpers src/index.ts:17-53. In contrast, specialized presets bypass default router selections by extending `HonoBase` directly with targeted routing engines src/preset/quick.ts:6-23, src/preset/tiny.ts:6-19. 

> [!NOTE]
> The `hono/quick` preset initializes a `SmartRouter` composed of `LinearRouter` and `TrieRouter` instances, whereas `hono/tiny` instantiates a single `PatternRouter` to minimize initialization overhead src/preset/quick.ts:20-22, src/preset/tiny.ts:18-18.


## Quick Preset Router Composition

### Smart Router Initialization and Composition

The `hono/quick` preset constructs an optimized subclass of `[[Application Core]]` by extending `HonoBase` and instantiating a `SmartRouter` within its constructor src/preset/quick.ts:13-23. Rather than binding to a single routing strategy, `SmartRouter` receives an array containing both a `LinearRouter` and a `TrieRouter` instance src/preset/quick.ts:20-22. 

```typescript
export class Hono<
  E extends Env = BlankEnv,
  S extends Schema = BlankSchema,
  BasePath extends string = '/',
> extends HonoBase<E, S, BasePath> {
  constructor(options: HonoOptions<E> = {}) {
    super(options)
    this.router = new SmartRouter({
      routers: [new LinearRouter(), new TrieRouter()],
    })
  }
```

> [!NOTE]
> The `hono/quick` preset relies on module resolution from `../router/linear-router`, `../router/smart-router`, and `../router/trie-router` to assemble its multi-strategy matching engine src/preset/quick.ts:8-10.


### Fallback Mechanics and Execution Flow

| Component Class | Import Path | Role in `SmartRouter` Composition |
| --------------- | ----------- | --------------------------------- |
| `LinearRouter` | `../router/linear-router` | Fast linear scanning for simpler route tables src/preset/quick.ts:8, src/preset/quick.ts:21 |
| `TrieRouter` | `../router/trie-router` | Prefix tree matching for complex parameter patterns src/preset/quick.ts:10, src/preset/quick.ts:21 |
| `SmartRouter` | `../router/smart-router` | Composite wrapper managing router selection and fallback src/preset/quick.ts:9, src/preset/quick.ts:20-22 |


## Tiny Preset for Constrained Runtimes

### Pattern-Based Dispatch Mechanics

The `hono/tiny` preset configures a minimal application footprint by extending `HonoBase` with the lightweight `PatternRouter` engine src/preset/tiny.ts:6-19. Instantiating `Hono` within this module assigns a `PatternRouter` directly to `this.router`, omitting complex multi-router selection logic and reducing overall binary weight for constrained execution environments src/preset/tiny.ts:16-19.

```typescript
export class Hono<
  E extends Env = BlankEnv,
  S extends Schema = BlankSchema,
  BasePath extends string = '/',
> extends HonoBase<E, S, BasePath> {
  constructor(options: HonoOptions<E> = {}) {
    super(options)
    this.router = new PatternRouter()
  }
}
```

> [!NOTE]
> The `hono/tiny` implementation accepts generic type parameters for environment bindings (`Env`), schema validation (`Schema`), and base path prefixes (`BasePath`), passing options directly to the `HonoBase` superclass constructor src/preset/tiny.ts:11-17.


### Class and Type Configuration

| Exported Symbol | Source Path | Type Definition / Role |
| --------------- | ----------- | ---------------------- |
| `Hono` | `src/preset/tiny.ts` | Subclass of `HonoBase` enforcing `PatternRouter` src/preset/tiny.ts:6-19 |
| `HonoBase` | `../hono-base` | Core routing and middleware execution engine src/preset/tiny.ts:6, src/preset/tiny.ts:15 |
| `PatternRouter` | `../router/pattern-router` | Lightweight pattern-matching router backend src/preset/tiny.ts:8, src/preset/tiny.ts:18 |
| `HonoOptions` | `../hono-base` | Configuration options interface for instantiation src/preset/tiny.ts:7, src/preset/tiny.ts:16 |


## Package Export Maps and Module Resolution

### Node.js Package Configuration and Conditional Exports

The `package.json` file establishes dual CommonJS and ES Module distribution channels alongside TypeScript declaration mappings package.json:5-8, package.json:37-42. The root export configuration maps types, ESM imports, and CommonJS requires for core modules, presets, middleware, helpers, and utilities package.json:37-144.

| Export Key | Types Path | Import Path (ESM) | Require Path (CJS) |
| ---------- | ---------- | ----------------- | ------------------ |
| `.` | `./dist/types/index.d.ts` package.json:39 | `./dist/index.js` package.json:40 | `./dist/cjs/index.js` package.json:41 |
| `./request` | `./dist/types/request.d.ts` package.json:44 | `./dist/request.js` package.json:45 | `./dist/cjs/request.js` package.json:46 |
| `./tiny` | `./dist/types/preset/tiny.d.ts` package.json:59 | `./dist/preset/tiny.js` package.json:60 | `./dist/cjs/preset/tiny.js` package.json:61 |
| `./quick` | `./dist/types/preset/quick.d.ts` package.json:64 | `./dist/preset/quick.js` package.json:65 | `./dist/cjs/preset/quick.js` package.json:66 |
| `./compress` | `./dist/types/middleware/compress/index.d.ts` package.json:114 | `./dist/middleware/compress/index.js` package.json:115 | `./dist/cjs/middleware/compress/index.js` package.json:116 |


> [!NOTE]
> The postbuild script executes `publint` to validate export map correctness, and copies `package.cjs.json` into distribution subdirectories to enforce CommonJS resolution boundaries package.json:28-30.


### JSR and Deno Module Resolution

The `jsr.json` manifest defines direct TypeScript source mappings for JSR distribution, targeting Deno and modern edge runtimes jsr.json:1-106. It enables the `sloppy-imports` unstable flag and specifies compiler options tailored for DOM and Deno namespaces jsr.json:4-7.

```json
"exports": {
  ".": "./src/index.ts",
  "./request": "./src/request.ts",
  "./types": "./src/types.ts",
  "./hono-base": "./src/hono-base.ts",
  "./tiny": "./src/preset/tiny.ts",
  "./quick": "./src/preset/quick.ts",
  "./http-exception": "./src/http-exception.ts",
  "./basic-auth": "./src/middleware/basic-auth/index.ts",
  "./bearer-auth": "./src/middleware/bearer-auth/index.ts",
  "./body-limit": "./src/middleware/body-limit/index.ts",
  "./ip-restriction": "./src/middleware/ip-restriction/index.ts",
  "./cache": "./src/middleware/cache/index.ts",
  "./route": "./src/helper/route/index.ts",
  "./cookie": "./src/helper/cookie/index.ts",
  "./accepts": "./src/helper/accepts/index.ts",
  "./compress": "./src/middleware/compress/index.ts",
  "./context-storage": "./src/middleware/context-storage/index.ts",
  "./cors": "./src/middleware/cors/index.ts",
  "./csrf": "./src/middleware/csrf/index.ts",
  "./etag": "./src/middleware/etag/index.ts",
  "./trailing-slash": "./src/middleware/trailing-slash/index.ts",
  "./html": "./src/helper/html/index.ts",
  "./css": "./src/helper/css/index.ts",
  "./jsx": "./src/jsx/index.ts",
  "./jsx/jsx-dev-runtime": "./src/jsx/jsx-dev-runtime.ts",
  "./jsx/jsx-runtime": "./src/jsx/jsx-runtime.ts",
  "./jsx/streaming": "./src/jsx/streaming.ts",
  "./jsx-renderer": "./src/middleware/jsx-renderer/index.ts",
```

Publish configuration within `jsr.json` explicitly includes source files, configuration manifests, and documentation while excluding test files jsr.json:107-110. Runtime test configurations like `runtime-tests/deno/deno.json` bind [JSX runtime](https://www.doc0.dev/docs/552ca36e-f67e-41c3-a07a-def9bd9551b0/jsx-and-ui/jsx-runtime) imports to local source files and configure standard library dependencies runtime-tests/deno/deno.json:1-13.


## Bundle Size Auditing and Enforcement

To prevent performance regressions and maintain minimal footprints across core distribution files, Hono uses an automated bundle measurement harness driven by `esbuild`. The check script compiles the built entry point `dist/index.js` into an isolated temporary file using production settings, extracts exact byte and kilobyte measurements, and outputs structured benchmark JSON for validation pipelines.

```typescript
async function main() {
  const tempDir = os.tmpdir()
  const tempFilePath = path.join(tempDir, 'bundle.tmp.js')

  try {
    await esbuild.build({
      entryPoints: ['dist/index.js'],
      bundle: true,
      minify: true,
      format: 'esm' as esbuild.Format,
      target: 'es2022',
      outfile: tempFilePath,
    })

    const bundleSize = fs.statSync(tempFilePath).size
    const metrics = []
```

| Configuration Property | Target Value | Purpose |
| ---------------------- | ------------ | ------- |
| `entryPoints` | `['dist/index.js']` | Specifies the compiled core bundle input file perf-measures/bundle-check/scripts/check-bundle-size.ts:12 |
| `bundle` | `true` | Resolves and inlines all internal module dependencies perf-measures/bundle-check/scripts/check-bundle-size.ts:13 |
| `minify` | `true` | Strips whitespace and mangles identifiers to measure production delivery size perf-measures/bundle-check/scripts/check-bundle-size.ts:14 |
| `format` | `'esm'` | Enforces ECMAScript module output format perf-measures/bundle-check/scripts/check-bundle-size.ts:15 |
| `target` | `'es2022'` | Sets the JavaScript language syntax target level perf-measures/bundle-check/scripts/check-bundle-size.ts:16 |
| `outfile` | `tempFilePath` | Writes output to an OS temporary directory path perf-measures/bundle-check/scripts/check-bundle-size.ts:17 |


> [!WARNING]
> The auditing harness guarantees cleanup by executing file deletion inside a `finally` block, ensuring temporary artifacts are wiped even if the compilation pass encounters errors perf-measures/bundle-check/scripts/check-bundle-size.ts:45-49.


## Related

- [Application Core](https://www.doc0.dev/docs/552ca36e-f67e-41c3-a07a-def9bd9551b0/core-engine/application-core)
- [Router Contracts](https://www.doc0.dev/docs/552ca36e-f67e-41c3-a07a-def9bd9551b0/routing/router-contracts)


## Sitemap

See the full [sitemap](https://www.doc0.dev/docs/552ca36e-f67e-41c3-a07a-def9bd9551b0/llms.txt) for all pages in this wiki.
