Browse documentation

SwOptions

Type. Configuration for service worker file generation.

Table of contents

Category

Type

Type import

ts
import type { sw } from "valyrian.js/node";
type SwOptions = NonNullable<Parameters<typeof sw>[1]>;

Public signature

ts
interface SwOptions {
  version?: string;
  name?: string;
  /** @deprecated Use criticalUrls instead */
  urls?: string[];
  criticalUrls?: string[];
  optionalUrls?: string[];
  debug?: boolean;
  logFetch?: boolean;
  offlinePage?: string;
}

Type usage

SwOptions is the option shape accepted by sw(file, options). criticalUrls block worker installation when precaching fails, while optionalUrls are cached without blocking installation.

Defaults

ts
version: "1"
name: "Valyrian.js"
criticalUrls: options.criticalUrls ?? options.urls ?? ["/"]
optionalUrls: []
debug: false
logFetch: false
offlinePage: "/offline.html"

Result

sw(...) returns void and writes the generated service worker to file. urls remains a deprecated fallback for criticalUrls.