diff --git a/islands/RegisterServiceWorker.tsx b/islands/RegisterServiceWorker.tsx new file mode 100644 index 0000000..1b33b4b --- /dev/null +++ b/islands/RegisterServiceWorker.tsx @@ -0,0 +1,7 @@ +export default function RegisterServiceWorker({ href }: { href: string }) { + if ('serviceWorker' in navigator) { + navigator.serviceWorker.register(href) + } + + return <> +} diff --git a/routes/_app.tsx b/routes/_app.tsx index 7d9f171..1636341 100644 --- a/routes/_app.tsx +++ b/routes/_app.tsx @@ -2,6 +2,7 @@ import { asset, Head, Partial } from '$fresh/runtime.ts' import { type PageProps } from '$fresh/server.ts' import { Footer } from '../components/Footer.tsx' import { Header } from '../components/Header.tsx' +import RegisterServiceWorker from '../islands/RegisterServiceWorker.tsx' export default function App({ Component }: PageProps) { return ( @@ -52,6 +53,7 @@ export default function App({ Component }: PageProps) { +