@swoff/cli
v0.3.13
Published
CLI for Swoff - Offline-first web apps made easy
Downloads
2,345
Maintainers
Readme
@swoff/cli
CLI for Swoff — offline-first web apps made easy.
Swoff generates a service worker and client-side utilities that give your web app server-state reactivity (stale-while-revalidate, auto-refetch, mutation tracking, dedup), offline support, and PWA features — zero runtime dependencies, all generated and auditable.
npx @swoff/cli init # create swoff.config.json
npx @swoff/cli generate # generate service worker + client filesThen import the single entry point:
import { initServiceWorker } from "swoff/client-injector.js";
initServiceWorker();Features
| Category | Feature | | ---------------------- | --------------------------------------------------- | | Caching | 6 strategies | | Mutations | useState-style tracking, offline queue, concurrency | | Prefetching | Cache warming on hover/navigation | | Dependent queries | enabled option, nullable URL | | Query cancellation | AbortController integration | | Real-time invalidation | SSE / WebSocket push events | | Tag invalidation | URL-derived cache tags | | Auth | memory-only tokens, bearer/cookie/custom | | GraphQL | body-hash caching, auto-tags | | PWA | install prompt, manifest, SW update hooks | | Push notifications | VAPID subscription management | | Background Sync | process mutations after tab close | | Cross-tab sync | broadcast invalidation across tabs |
CLI Commands
| Command | Description |
| ---------------- | ---------------------------------------------- |
| init | Create swoff.config.json with auto-detection |
| generate | Generate SW + all supporting files |
| add <feature> | Enable a feature and regenerate |
| validate | Validate swoff.config.json |
| info [feature] | Show summary or per-feature details |
| clean | Remove all generated files and config |
| help [command] | Show help for a specific command |
For PWA asset generation (icons, splash screens, favicons, manifest.json), use the standalone @swoff/assets package:
npx @swoff/assets --source ./logo.svgConfiguration
Create swoff.config.json with swoff init, then tweak as needed.
Full schema reference in docs/CONFIG.md.
API Reference
Read the API reference for detailed information on each API.
CLI Reference
Read the CLI reference for detailed information on each command.
Architecture
Read the architecture for detailed information on the project's architecture.
Comparison With Other Popular Tools
Read the comparison for a comprehensive comparison with popular tools.
Ecosystem
Read the ecosystem to see how swoff integrates with any web framework you can work with.
Requirements
- Node.js >= 18
- A build tool with a
package.jsonbuild script - Secure Context (required for service workers)
License
MIT
Source: github.com/iamsuudi/swoff
