Framework-Agnostic Patterns
Copy-paste code for offline-first apps — zero dependencies.
Patterns
Framework-agnostic JavaScript you copy into your project. Modify them to fit your needs.
SW Template
Versioned service worker with cache-first, stale-while-revalidate, and network-first strategies.
Build Scripts
Generate versioned SW + version.json from your package.json.
Client Registration
Register SW with version checking, update prompts, and progress tracking.
API Integration
Coordinate client fetches with SW cache strategies, tags, and invalidation.
Invalidation Tags
URL-based tag generation from REST endpoints for automatic cache invalidation.
PWA Installability
Manifest, install prompt, and PWA detection for installable apps.
IndexedDB Patterns
Native API and optional idb wrapper with schema migrations and
quota management.
TypeScript Declarations
Type declarations for SW window properties and helper functions.
Learning Path
Concepts (/docs/concepts/)
↓
Core Architecture (/docs/core/)
↓
Patterns (you are here) ← Copy this JavaScript into your project
↓
Integration (/docs/integration/) ← Understand the bridge to frameworks
↓
Framework Guides (/docs/guides/) ← Framework-specific setup & adaptersNext Steps
- Start with the SW Template — the foundation
- API Integration — coordinate client fetches with the SW
Swoff