Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/api/hono.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ If both a parent app and its routes have `onError` handlers, the route-level han
## fire()

::: warning
**`app.fire()` is deprecated**. Use `fire()` from `hono/service-worker` instead. See the [Service Worker documentation](/docs/getting-started/service-worker) for details.
**`app.fire()` is deprecated**. Use `fire()` from `@hono/service-worker` instead. See the [Service Worker documentation](/docs/getting-started/service-worker) for details.
:::

`app.fire()` automatically adds a global `fetch` event listener.
Expand Down
24 changes: 12 additions & 12 deletions docs/getting-started/aws-lambda.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Initialize your project with the `cdk` CLI.
mkdir my-app
cd my-app
cdk init app -l typescript
npm i hono
npm i hono @hono/aws-lambda
npm i -D esbuild
mkdir lambda
touch lambda/index.ts
Expand All @@ -29,7 +29,7 @@ touch lambda/index.ts
mkdir my-app
cd my-app
cdk init app -l typescript
yarn add hono
yarn add hono @hono/aws-lambda
yarn add -D esbuild
mkdir lambda
touch lambda/index.ts
Expand All @@ -39,7 +39,7 @@ touch lambda/index.ts
mkdir my-app
cd my-app
cdk init app -l typescript
pnpm add hono
pnpm add hono @hono/aws-lambda
pnpm add -D esbuild
mkdir lambda
touch lambda/index.ts
Expand All @@ -49,7 +49,7 @@ touch lambda/index.ts
mkdir my-app
cd my-app
cdk init app -l typescript
bun add hono
bun add hono @hono/aws-lambda
bun add -D esbuild
mkdir lambda
touch lambda/index.ts
Expand All @@ -63,7 +63,7 @@ Edit `lambda/index.ts`.

```ts
import { Hono } from 'hono'
import { handle } from 'hono/aws-lambda'
import { handle } from '@hono/aws-lambda'

const app = new Hono()

Expand Down Expand Up @@ -128,8 +128,8 @@ In Hono, you can access the AWS Lambda Events and Context by binding the `Lambda

```ts
import { Hono } from 'hono'
import type { LambdaEvent, LambdaContext } from 'hono/aws-lambda'
import { handle } from 'hono/aws-lambda'
import type { LambdaEvent, LambdaContext } from '@hono/aws-lambda'
import { handle } from '@hono/aws-lambda'

type Bindings = {
event: LambdaEvent
Expand All @@ -154,8 +154,8 @@ In Hono, you can access the AWS Lambda request context by binding the `LambdaEve

```ts
import { Hono } from 'hono'
import type { LambdaEvent } from 'hono/aws-lambda'
import { handle } from 'hono/aws-lambda'
import type { LambdaEvent } from '@hono/aws-lambda'
import { handle } from '@hono/aws-lambda'

type Bindings = {
event: LambdaEvent
Expand All @@ -177,8 +177,8 @@ you can access the AWS Lambda request context by binding the `ApiGatewayRequestC

```ts
import { Hono } from 'hono'
import type { ApiGatewayRequestContext } from 'hono/aws-lambda'
import { handle } from 'hono/aws-lambda'
import type { ApiGatewayRequestContext } from '@hono/aws-lambda'
import { handle } from '@hono/aws-lambda'

type Bindings = {
requestContext: ApiGatewayRequestContext
Expand Down Expand Up @@ -209,7 +209,7 @@ Typically, the implementation requires writing chunks to NodeJS.WritableStream u

```ts
import { Hono } from 'hono'
import { streamHandle } from 'hono/aws-lambda'
import { streamHandle } from '@hono/aws-lambda'
import { streamText } from 'hono/streaming'

const app = new Hono()
Expand Down
4 changes: 2 additions & 2 deletions docs/getting-started/basic.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,10 @@ And, you can make your own middleware.
## Adapter

There are Adapters for platform-dependent functions, e.g., handling static files or WebSocket.
For example, to handle WebSocket in Cloudflare Workers, import `hono/cloudflare-workers`.
They are published as separate packages. For example, to handle WebSocket in Cloudflare Workers, install and import `@hono/cloudflare-workers`.

```ts
import { upgradeWebSocket } from 'hono/cloudflare-workers'
import { upgradeWebSocket } from '@hono/cloudflare-workers'

app.get(
'/ws',
Expand Down
8 changes: 6 additions & 2 deletions docs/getting-started/bun.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,14 @@ export default { // [!code ++]

## Serve static files

To serve static files, use `serveStatic` which is imported from `hono/bun`.
To serve static files, use `serveStatic` from the `@hono/bun` package.

```sh
bun add @hono/bun
```

```ts
import { serveStatic } from 'hono/bun'
import { serveStatic } from '@hono/bun'

const app = new Hono()

Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started/cloudflare-pages.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Cloudflare Pages

::: warning
For new projects, Cloudflare now recommends using [Cloudflare Workers](/docs/getting-started/cloudflare-workers) instead of Cloudflare Pages. Workers supports static assets and offers a broader set of features. If you are starting a new full-stack application, see [Cloudflare Workers + Vite](/docs/getting-started/cloudflare-workers-vite), which is the successor to this Pages setup.
For new projects, Cloudflare now recommends using [Cloudflare Workers](/docs/getting-started/cloudflare-workers) instead of Cloudflare Pages. Workers supports static assets and offers a broader set of features. If you are starting a new full-stack application, see [Cloudflare Workers + Vite](/docs/getting-started/cloudflare-workers-vite), which is the successor to this Pages setup. The `hono/cloudflare-pages` adapter is deprecated and will be removed in Hono v5.
:::

[Cloudflare Pages](https://pages.cloudflare.com) is an edge platform for full-stack web applications.
Expand Down
8 changes: 6 additions & 2 deletions docs/getting-started/deno.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,15 @@ Deno.serve({ port: 8787 }, app.fetch) // [!code ++]

## Serve static files

To serve static files, use `serveStatic` imported from `hono/deno`.
To serve static files, use `serveStatic` from the `@hono/deno` package.

```sh
deno add jsr:@hono/deno
```

```ts
import { Hono } from 'hono'
import { serveStatic } from 'hono/deno'
import { serveStatic } from '@hono/deno'

const app = new Hono()

Expand Down
14 changes: 7 additions & 7 deletions docs/getting-started/lambda-edge.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,31 @@ Initialize your project with the `cdk` CLI.
mkdir my-app
cd my-app
cdk init app -l typescript
npm i hono
npm i hono @hono/lambda-edge
mkdir lambda
```

```sh [yarn]
mkdir my-app
cd my-app
cdk init app -l typescript
yarn add hono
yarn add hono @hono/lambda-edge
mkdir lambda
```

```sh [pnpm]
mkdir my-app
cd my-app
cdk init app -l typescript
pnpm add hono
pnpm add hono @hono/lambda-edge
mkdir lambda
```

```sh [bun]
mkdir my-app
cd my-app
cdk init app -l typescript
bun add hono
bun add hono @hono/lambda-edge
mkdir lambda
```

Expand All @@ -54,7 +54,7 @@ Edit `lambda/index_edge.ts`.

```ts
import { Hono } from 'hono'
import { handle } from 'hono/lambda-edge'
import { handle } from '@hono/lambda-edge'

const app = new Hono()

Expand Down Expand Up @@ -135,8 +135,8 @@ If you want to add Basic Auth and continue with request processing after verific
```ts
import { Hono } from 'hono'
import { basicAuth } from 'hono/basic-auth'
import type { Callback, CloudFrontRequest } from 'hono/lambda-edge'
import { handle } from 'hono/lambda-edge'
import type { Callback, CloudFrontRequest } from '@hono/lambda-edge'
import { handle } from '@hono/lambda-edge'

type Bindings = {
callback: Callback
Expand Down
4 changes: 2 additions & 2 deletions docs/getting-started/netlify.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Edit `netlify/edge-functions/index.ts`:

```ts
import { Hono } from 'jsr:@hono/hono'
import { handle } from 'jsr:@hono/hono/netlify'
import { handle } from 'jsr:@hono/netlify'

const app = new Hono()

Expand Down Expand Up @@ -75,7 +75,7 @@ You can access the Netlify's `Context` through `c.env`:

```ts
import { Hono } from 'jsr:@hono/hono'
import { handle } from 'jsr:@hono/hono/netlify'
import { handle } from 'jsr:@hono/netlify'

// Import the type definition
import type { Context } from 'https://edge.netlify.com/'
Expand Down
4 changes: 3 additions & 1 deletion docs/getting-started/nextjs.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ If you use the App Router, Edit `app/api/[[...route]]/route.ts`. Refer to the [S

```ts
import { Hono } from 'hono'
import { handle } from 'hono/vercel'
import { handle } from '@hono/vercel'

const app = new Hono().basePath('/api')

Expand All @@ -78,6 +78,8 @@ app.get('/hello', (c) => {
})

export const GET = handle(app)

`handle` comes from the `@hono/vercel` package, which the starter installs. On an existing project, add it with `npm i @hono/vercel`.
export const POST = handle(app)
```

Expand Down
12 changes: 6 additions & 6 deletions docs/getting-started/service-worker.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,22 @@ Next, install the necessary modules.
::: code-group

```sh [npm]
npm i hono
npm i hono @hono/service-worker
npm i -D vite
```

```sh [yarn]
yarn add hono
yarn add hono @hono/service-worker
yarn add -D vite
```

```sh [pnpm]
pnpm add hono
pnpm add hono @hono/service-worker
pnpm add -D vite
```

```sh [bun]
bun add hono
bun add hono @hono/service-worker
bun add -D vite
```

Expand Down Expand Up @@ -118,7 +118,7 @@ In `sw.ts`, create an application using Hono and register it to the `fetch` even
declare const self: ServiceWorkerGlobalScope

import { Hono } from 'hono'
import { handle } from 'hono/service-worker'
import { handle } from '@hono/service-worker'

const app = new Hono().basePath('/sw')
app.get('/', (c) => c.text('Hello World'))
Expand All @@ -132,7 +132,7 @@ The `fire()` function automatically calls `addEventListener('fetch', handle(app)

```ts
import { Hono } from 'hono'
import { fire } from 'hono/service-worker'
import { fire } from '@hono/service-worker'

const app = new Hono().basePath('/sw')
app.get('/', (c) => c.text('Hello World'))
Expand Down
16 changes: 9 additions & 7 deletions docs/helpers/conninfo.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,43 @@ The ConnInfo Helper helps you to get the connection information. For example, yo

## Import

The adapter for each runtime is a separate package (`@hono/cloudflare-workers`, `@hono/deno`, `@hono/bun`, ...). Install the one for your runtime.

::: code-group

```ts [Cloudflare Workers]
import { Hono } from 'hono'
import { getConnInfo } from 'hono/cloudflare-workers'
import { getConnInfo } from '@hono/cloudflare-workers'
```

```ts [Deno]
import { Hono } from 'hono'
import { getConnInfo } from 'hono/deno'
import { getConnInfo } from '@hono/deno'
```

```ts [Bun]
import { Hono } from 'hono'
import { getConnInfo } from 'hono/bun'
import { getConnInfo } from '@hono/bun'
```

```ts [Vercel]
import { Hono } from 'hono'
import { getConnInfo } from 'hono/vercel'
import { getConnInfo } from '@hono/vercel'
```

```ts [AWS Lambda]
import { Hono } from 'hono'
import { getConnInfo } from 'hono/aws-lambda'
import { getConnInfo } from '@hono/aws-lambda'
```

```ts [Netlify]
import { Hono } from 'hono'
import { getConnInfo } from 'hono/netlify'
import { getConnInfo } from '@hono/netlify'
```

```ts [Lambda@Edge]
import { Hono } from 'hono'
import { getConnInfo } from 'hono/lambda-edge'
import { getConnInfo } from '@hono/lambda-edge'
```

```ts [Node.js]
Expand Down
6 changes: 3 additions & 3 deletions docs/helpers/ssg.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,20 @@ export interface FileSystemModule {

### Using adapters for Deno and Bun

If you want to use SSG on Deno or Bun, a `toSSG` function is provided for each file system.
If you want to use SSG on Deno or Bun, a `toSSG` function is provided by the `@hono/deno` and `@hono/bun` packages.

For Deno:

```ts
import { toSSG } from 'hono/deno'
import { toSSG } from '@hono/deno'

toSSG(app) // The second argument is an option typed `ToSSGOptions`.
```

For Bun:

```ts
import { toSSG } from 'hono/bun'
import { toSSG } from '@hono/bun'

toSSG(app) // The second argument is an option typed `ToSSGOptions`.
```
Expand Down
Loading
Loading