Worker exports
Introduction
@serwist/next
exports a few things for the service worker to consume. These values are available at @serwist/next/worker
.
Exported values
defaultCache
Type:
RuntimeCaching[]
What:
@serwist/next
's recommended list of caching strategies.How to use:
import {
defaultCache } from "@serwist/next/worker"; import type {PrecacheEntry ,SerwistGlobalConfig } from "serwist"; import {Serwist } from "serwist"; declareglobal { interfaceWorkerGlobalScope extendsSerwistGlobalConfig { // Change this attribute's name to your `injectionPoint`. // `injectionPoint` is an InjectManifest option. // See https://serwist.pages.dev/docs/build/configuring__SW_MANIFEST : (PrecacheEntry | string)[] | undefined; } } declare constself :ServiceWorkerGlobalScope ; constserwist = newSerwist ({precacheEntries :self .__SW_MANIFEST ,skipWaiting : true,clientsClaim : true,navigationPreload : true,runtimeCaching :defaultCache , });serwist .addEventListeners ();