/Knowledge/sources/honojs__hono/llms-full/service-worker-hello-world--part-02--3ecb8d14128c.md
Service Worker: Hello World (part 02) - hono-docs
Service Worker: Hello World (part 02) Source evidence: /Sources/honojs hono/provenance.md Canonical citation: https://hono.dev/llms full.txt 2 hello world Su...
Service Worker: Hello World (part 02)
Source evidence: /Sources/honojs__hono/provenance.md Canonical citation: https://hono.dev/llms-full.txt#2-hello-world
Summary
In sw.ts, create an application using Hono and register it to the fetch event with the Service Worker adapter’s handle function. This allows the Hono application to intercept access to /sw. ```ts // To support types // https://gi...
Content
In sw.ts, create an application using Hono and register it to the fetch event with the Service Worker adapter’s handle function. This allows the Hono application to intercept access to /sw.
// To support types
// https://github.com/microsoft/TypeScript/issues/14877
declare const self: ServiceWorkerGlobalScope
import { Hono } from 'hono'
import { handle } from 'hono/service-worker'
const app = new Hono().basePath('/sw')
app.get('/', (c) => c.text('Hello World'))
self.addEventListener('fetch', handle(app))
Metadata
{
"chunk_index": 1,
"citation": "https://hono.dev/llms-full.txt#2-hello-world",
"coverage_role": "overview",
"qualified_title": "Hono / llms-full / Service Worker > 2. Hello World (2)",
"retrieved_at": "2026-07-02T05:51:01Z",
"section_index": 482,
"source_id": "/honojs/hono",
"source_type": "llms_full",
"target_label": "llms-full",
"title": "Service Worker: Hello World (part 02)",
"upstream_url": "https://hono.dev/llms-full.txt",
"version": "2026"
}