Skip to main content
This release is 7 versions behind 4.7.7 — the latest version of @hono/hono. Jump to latest

@hono/hono@4.6.20
Built and signed on GitHub Actions

Web framework built on Web Standards

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
76%
Published
3 months ago (4.6.20)

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

class HonoBase

Constructors

new
HonoBase(options?: HonoOptions<E>)

Type Parameters

E extends Env = Env
S extends Schema = { }
BasePath extends string = "/"

Properties

fetch: (
request: Request,
Env?: E["Bindings"] | { },
executionCtx?: ExecutionContext,
) => Response | Promise<Response>

.fetch() will be entry point of your app.

fire: () => void

.fire() automatically adds a global fetch event listener. This can be useful for environments that adhere to the Service Worker API, such as non-ES module Cloudflare Workers.

readonly
getPath: GetPath<E>
notFound: (handler: NotFoundHandler<E>) => Hono<E, S, BasePath>

.notFound() allows you to customize a Not Found Response.

onError: (handler: ErrorHandler<E>) => Hono<E, S, BasePath>

.onError() handles an error and returns a customized Response.

request: (
input: RequestInfo | URL,
requestInit?: RequestInit,
Env?: E["Bindings"] | { },
executionCtx?: ExecutionContext,
) => Response | Promise<Response>

.request() is a useful method for testing. You can pass a URL or pathname to send a GET request. app will return a Response object.

test('GET /hello is ok', async () => {
  const res = await app.request('/hello')
  expect(res.status).toBe(200)
})

Methods

basePath<SubPath extends string>(path: SubPath): Hono<E, S, MergePath<BasePath, SubPath>>

.basePath() allows base paths to be specified.

mount(
path: string,
applicationHandler: (
request: Request,
...args: any,
) => Response | Promise<Response>
,
options?: MountOptions,
): Hono<E, S, BasePath>

.mount() allows you to mount applications built with other frameworks into your Hono application.

route<
SubPath extends string,
SubEnv extends Env,
SubSchema extends Schema,
SubBasePath extends string,
>
(
path: SubPath,
app: Hono<SubEnv, SubSchema, SubBasePath>,
): Hono<E, MergeSchemaPath<SubSchema, MergePath<BasePath, SubPath>> | S, BasePath>

.route() allows grouping other Hono instance in routes.

Add Package

deno add jsr:@hono/hono

Import symbol

import { HonoBase } from "@hono/hono/hono-base";

---- OR ----

Import directly with a jsr specifier

import { HonoBase } from "jsr:@hono/hono/hono-base";

Add Package

npx jsr add @hono/hono

Import symbol

import { HonoBase } from "@hono/hono/hono-base";

Add Package

yarn dlx jsr add @hono/hono

Import symbol

import { HonoBase } from "@hono/hono/hono-base";

Add Package

pnpm dlx jsr add @hono/hono

Import symbol

import { HonoBase } from "@hono/hono/hono-base";

Add Package

bunx jsr add @hono/hono

Import symbol

import { HonoBase } from "@hono/hono/hono-base";