Swoff Swoff

Schema Reference

Complete swoff.config.json field reference.

Configuration Schema

Full schema at https://swoff.netlify.app/schema/v1.json.

Root

FieldTypeDefaultDescription
$schemastring"https://swoff.netlify.app/schema/v1.json"JSON Schema URL for IDE autocompletion
enabledbooleantrueEnable config-driven SW generation. Set false to write your own SW manually
versionstring"from-package"SW version. Use "from-package" to read from package.json, or specify semver like "1.0.0"
minSupportedVersionstring"0.0.0"Force update for clients running older versions

serviceWorker

FieldTypeDefaultDescription
autoRegisterbooleantrueAuto-register new SW versions on page load. Set false for consent-based registration
autoActivatebooleanfalseAuto-activate new SW via skipWaiting. Only applies when autoRegister or handleUpdateApproved() registers a new version

serviceWorker.strategy

FieldTypeDefaultDescription
defaultstring"cache-first"Default caching strategy for unmatched routes
patternsobject{}Per-URL pattern strategy overrides
modestring"all"Controls which requests are processed by the SW cache strategy system. "all" processes every GET/HEAD request. "explicit-only" only processes requests with X-SW-Cache-Strategy header
clearRuntimeOnUpdatebooleanfalseDelete runtime cache on SW activate. Use as a security measure — cached API responses are cleared on every SW update, preventing poisoned data from persisting
normalizeKeybooleanfalseNormalize cache keys by lowercasing and sorting query params. Reduces cache fragmentation
ignoreQueryParamsstring[][]Query parameter names to ignore when matching cache keys. Useful for Analytics/UTM params that should not create separate cache entries

serviceWorker.navigation

FieldTypeDefaultDescription
modestring"spa"How navigation requests are handled. "spa" falls back to fallback on cache miss. "default" uses the strategy as-is
preloadbooleantrueEnable Navigation Preload API in the service worker. Reduces startup latency for navigation requests
fallbackstring"/index.html"Fallback URL for navigation requests when navigation.mode is "spa"

Strategy Values

  • cache-first — Serve from cache, fall back to network
  • network-first — Try network, fall back to cache
  • stale-while-revalidate — Serve cached, refresh in background
  • cache-only — Cache only (never network)
  • network-only — Network only (never cache)

features

All features are nested under the features key.

Boolean Features

FieldTypeDefaultDescription
versionedSwbooleantrueVersioned SW lifecycle (install, activate, skipWaiting)
mutationQueuebooleanfalseQueue offline writes, sync on reconnect
backgroundSyncbooleanfalseBackground Sync API (Chrome/Edge only). Requires mutationQueue: true
crossTabSyncbooleantrueCross-tab cache invalidation via postMessage. Requires tagInvalidation: true
tagInvalidationbooleantrueURL-based cache tag generation
clientRegistrationbooleantrueGenerate sw-injector.js with version checking and update consent

Object Features

pwa

FieldTypeDefaultDescription
enabledbooleantrueGenerate PWA install handler + manifest.json
preventDefaultInstallbooleanfalseSuppress native install prompt. When true, dev must call promptInstall() manually

auth

FieldTypeDefaultDescription
enabledbooleanfalseGenerate auth integration (auth-store, auth-fetch, auth-user, auth-state)
typestring"bearer"Auth mechanism. "cookie" — httpOnly cookies (auto-sent by browser). "bearer" — bearer token in memory only. "custom" — implement your own withAuthHeaders()
refreshPathstring"/api/refresh"Token refresh endpoint path
userEndpointstring"/api/me"User info endpoint path

indexeddb

FieldTypeDefaultDescription
enabledbooleanfalseGenerate IndexedDB storage patterns
namestring"app-db"IndexedDB database name
storesarray[]Array of object store names (user defines their own schema)

build

FieldTypeDefaultDescription
outputDirstring"dist"Build output directory for SW + version.json
swFilenamestring"sw"SW filename (without version). Produces <swFilename>-v<version>.js

Manifest

The CLI generates public/manifest.json when features.pwa.enabled is true, but only if:

  • The public/ directory exists at project root
  • No public/manifest.json already exists

The generated manifest includes full PWA fields (name, short_name, icons, start_url, display, background_color, theme_color, description, scope, categories, lang, orientation).

Example Config

{
  "$schema": "https://swoff.netlify.app/schema/v1.json",
  "enabled": true,
  "version": "from-package",
  "minSupportedVersion": "1.0.0",
  "serviceWorker": {
    "autoRegister": true,
    "autoActivate": false,
    "strategy": {
      "default": "cache-first",
      "patterns": {
        "/api/*": "network-first",
        "/static/*": "cache-first"
      },
      "mode": "all",
      "clearRuntimeOnUpdate": false,
      "normalizeKey": false,
      "ignoreQueryParams": []
    },
    "navigation": {
      "mode": "spa",
      "preload": true,
      "fallback": "/index.html"
    }
  },
  "features": {
    "versionedSw": true,
    "mutationQueue": false,
    "backgroundSync": false,
    "pwa": { "enabled": true, "preventDefaultInstall": false },
    "auth": { "enabled": false, "type": "bearer", "refreshPath": "/api/refresh", "userEndpoint": "/api/me" },
    "crossTabSync": true,
    "tagInvalidation": true,
    "clientRegistration": true,
    "indexeddb": { "enabled": false, "name": "app-db", "stores": [] }
  },
  "build": {
    "outputDir": "dist",
    "swFilename": "sw"
  }
}

Validation

Validate your config against the schema:

npx @swoff/cli validate

On this page