/Wiki/sources/honojs__hono/2026/https-hono-dev-llms-full-txt-2-hello-world-a0ae090da402-2-hello-world-s0482-c0000.md
2. Hello World (1) - hono-docs
2. Hello World (1) Source evidence: /Sources/raw/honojs hono/honojs hono.md Canonical citation: https://hono.dev/llms full.txt 2 hello world Summary Edit ind...
2. Hello World (1)
Source evidence: /Sources/raw/honojshono/honojshono.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()