summaryrefslogtreecommitdiff
path: root/apps/web/app/sw.ts
diff options
context:
space:
mode:
Diffstat (limited to 'apps/web/app/sw.ts')
-rw-r--r--apps/web/app/sw.ts22
1 files changed, 22 insertions, 0 deletions
diff --git a/apps/web/app/sw.ts b/apps/web/app/sw.ts
new file mode 100644
index 0000000..894c9ae
--- /dev/null
+++ b/apps/web/app/sw.ts
@@ -0,0 +1,22 @@
+/// <reference lib="webworker" />
+import { defaultCache } from "@serwist/next/worker"
+import type { PrecacheEntry, SerwistGlobalConfig } from "serwist"
+import { Serwist } from "serwist"
+
+declare global {
+ interface WorkerGlobalScope extends SerwistGlobalConfig {
+ __SW_MANIFEST: (PrecacheEntry | string)[] | undefined
+ }
+}
+
+declare const self: ServiceWorkerGlobalScope
+
+const serwist = new Serwist({
+ precacheEntries: self.__SW_MANIFEST,
+ skipWaiting: true,
+ clientsClaim: true,
+ navigationPreload: true,
+ runtimeCaching: defaultCache,
+})
+
+serwist.addEventListeners()