/Knowledge/sources/honojs__hono/llms-full/service-worker-hello-world--d31c024b7371.md
Service Worker: Hello World - hono-docs
Service Worker: Hello World Source evidence: /Sources/honojs hono/provenance.md Canonical citation: https://hono.dev/llms full.txt 2 hello world Summary Edit...
Service Worker: Hello World
Source evidence: /Sources/honojs__hono/provenance.md Canonical citation: https://hono.dev/llms-full.txt#2-hello-world
Summary
Edit index.html: html Hello World by Service Worker main.ts is a script to register the Service Worker: ```ts function register() { navigator.serviceWorker .register('/sw.ts', { scope: '/sw', type: 'module' }) .then( function...
Content
Edit index.html:
<!doctype html>
<html>
<body>
<a href="/sw">Hello World by Service Worker</a>
<script type="module" src="/main.ts"></script>
</body>
</html>
main.ts is a script to register the Service Worker:
function register() {
navigator.serviceWorker
.register('/sw.ts', { scope: '/sw', type: 'module' })
.then(
function (_registration) {
console.log('Register Service Worker: Success')
},
function (_error) {
console.log('Register Service Worker: Error')
}
)
}
function start() {
navigator.serviceWorker
.getRegistrations()
.then(function (registrations) {
for (const registration of registrations) {
console.log('Unregister Service Worker')
registration.unregister()
}
register()
})
}
start()
Metadata
{
"chunk_index": 0,
"citation": "https://hono.dev/llms-full.txt#2-hello-world",
"coverage_role": "overview",
"qualified_title": "Hono / llms-full / Service Worker > 2. Hello World (1)",
"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",
"upstream_url": "https://hono.dev/llms-full.txt",
"version": "2026"
}