A config-driven code generator for offline-first web apps. One swoff.config.json drives caching, auth, offline queue, push, and PWA — with any frontend, backend, or build tool. The output is auditable vanilla JS you own, with zero runtime dependencies.
Try it in 2 minutes
# 1. Init config (or --yes for defaults)
npx @swoff/cli init
# 2. Generate your swoff/ runtime
npx @swoff/cli generate
# 3. Build step — embed your assets
node swoff/sw/generator.mjs
# 4. Include the injector in your HTML
Bundler:
import { initServiceWorker } from "./swoff/client-injector";
initServiceWorker();
No-bundler:
<script src="/swoff/client-injector.bundle.js"></script>Not just a service worker — a complete offline-first platform generated from a single config file.
Six strategies with per-route pattern overrides, HTML cache isolation, request batching, and reactive stale-time refreshes.
IndexedDB write queue with reconnect replay, exponential backoff, and batch processing.
Cookie, bearer, or custom auth with token refresh, 401 detection, SW bypass, and cross-tab clearAuth().
Notifications from config, installability, and full PWA asset generation from a single SVG source.
SSE/WebSocket server push in the SW scope, plus body-hash caching and op-name tag invalidation for GraphQL.
Invalidation, auth, and mutation events broadcast to every tab through the SW message hub.
Swoff operates at the fetch event layer — below frameworks and bundlers. Compatible with any frontend, any backend, any build tool.
@swoff/assets generates 50+ production-ready PWA assets from a single source image — or a wordmark — including manifest and HTML head tags. No service worker, no build tool, no framework required.
npx @swoff/assets --source ./logo.svgThen paste the generated swoff-head-tags.html into your HTML <head> (or meta-framework head API) — the manifest and icons only take effect once linked.