SwoffSwoff

Feature Map

Every Swoff feature, module-by-module — what it gives you, how to enable it, and how it compares to other libraries.

A single-page map of every Swoff feature. Start with npx @swoff/cli init, pick the features your app needs, and Swoff generates offline infrastructure — service worker, caches, auth, mutations — from your config. Everything here is module-by-module: what it does, how to turn it on, what it depends on, and which libraries solve the same problem.

Start

npx @swoff/cli init
npx @swoff/cli generate
node swoff/sw/generator.mjs
  1. init — writes swoff.config.json.
  2. generate — produces the swoff/ source modules (fetch, cache, auth, mutation, …).
  3. generator.mjs — a build step (added to your build script) that scans built assets and writes the final sw.js.

Register the service worker in your app entry:

import { initServiceWorker } from "./swoff/client-injector";
initServiceWorker();

See the CLI reference and Build config for the full workflow.

Feature map

Two layers. Top-level features (features.*) are independent capabilities. Caching sub-features live under the features.caching umbrella and all activate through it. Solid edges are dependencies; dashed edges carry extra constraints.

Rules the map implies:

  • The umbrella gates everything cache-related. Any caching sub-feature needs features.caching.enabled: true. When it's false, the SW has no fetch listener.
  • Every sub-feature is opt-in with an explicit enabled: true — including tagInvalidation. Its fetch/core, cache/tags, and cache/invalidate modules are only generated when features.caching.tagInvalidation.enabled is true.
  • Background sync and server push need cookie auth — they run in the SW scope with no DOM to refresh bearer tokens.
  • strategy.reactive is generated only when strategy.default is "reactive".

Module timeline

How the features stack, top to bottom — each is an accordion you can expand. §6 (the caching umbrella) holds its sub-features as a nested accordion. Click a title to open its details.

Next steps

  • Deep library-by-library matrices: Library Comparison
  • Config schema for every feature: Config Reference
  • All generated APIs: API Reference
  • Design rationale and internal mechanics: Architecture
  • Per-ecosystem setup: Framework Integration

On this page