Serwist
A maintained fork of Workbox for building progressive web apps with service worker precaching and caching
Repository Health
Technical Analysis
Serwist is a service worker toolkit forked from Google’s Workbox after Workbox’s development stalled. The core serwist package provides precaching, route matching, and configurable runtime caching strategies (cache-first, network-first, stale-while-revalidate, and more) for building progressive web apps with reliable offline support.
Beyond the core runtime library, the monorepo ships build-tool integrations — @serwist/next, @serwist/vite, @serwist/nuxt, @serwist/svelte, and @serwist/webpack-plugin — that generate and inject a service worker into an app’s build pipeline, plus @serwist/window for registering and communicating with the service worker from the page, and a CLI for standalone service worker builds outside a bundler integration.
What You Get
- A
Serwistruntime class combining precaching, routing, and caching strategy configuration in one API - Built-in caching strategies (CacheFirst, NetworkFirst, StaleWhileRevalidate, NetworkOnly, CacheOnly) with plugin hooks
- Precache manifest injection so build tools can list exactly which assets to cache at install time
- First-party integrations for Next.js, Vite, Nuxt, Svelte(Kit), and Webpack that wire service worker generation into the build
- A
@serwist/windowclient library for registering the service worker and listening for update/waiting events from the page - A standalone CLI for generating a service worker outside of a supported bundler integration
Common Use Cases
- Adding offline support and asset precaching to a Next.js, Vite, or Nuxt application
- Migrating an existing Workbox-based service worker setup to a project with active maintenance and modern tooling
- Implementing custom runtime caching strategies for API responses, images, or fonts in a progressive web app
- Prompting users to refresh when a new service worker version is available via
@serwist/window’s update events - Building an installable, offline-capable web app without hand-writing raw service worker cache logic
Under The Hood
Architecture The monorepo (managed with pnpm workspaces and Turborepo) centers on packages/core, published as serwist, which exposes a Serwist class (src/Serwist.ts) that composes Route/RegExpRoute/NavigationRoute matchers with a PrecacheRoute for cache-manifest-driven precaching; framework packages (packages/next, packages/vite, packages/nuxt, packages/svelte, packages/webpack-plugin) each wrap the core library with build-tool-specific manifest injection so the correct list of build assets gets precached automatically. Tech Stack Written in TypeScript targeting the Service Worker and Cache Storage web APIs directly (no bundler-specific runtime dependency in core), with framework packages depending on their respective build tool APIs (webpack compiler hooks, Vite plugin API, Next.js config) and @serwist/build sharing manifest-generation logic across them. Code Quality The project carries over Workbox’s original test suite (under __tests__) plus its own additions, uses Biome for linting/formatting, and TypeScript strict mode across packages; being an actively maintained fork of an established Google project gives it a mature, well-exercised caching-strategy implementation rather than a from-scratch rewrite. API Design The Serwist class API is close to a drop-in replacement for Workbox’s, easing migration, while each framework package reduces setup to a config object (e.g. withSerwist() in next.config.js) so most projects need only a few lines of configuration rather than hand-authoring service worker registration and caching logic.