# Service worker / offline support

Feature 14 of 14, in the group "Other features". Labels across 23 meta-frameworks: 2 1st-party, 1 Experimental, 3 Third-party, 17 Manual.

## What it is and why it matters

A service worker is a script the browser keeps between visits. It can answer requests from a cache it filled earlier. It does nothing for a first visit, because it installs after the page has loaded. On repeat visits it can serve the built JS and CSS without a network round trip, and it can keep pages working offline. The row is ✅ when the framework builds and registers a service worker and gives it the list of built assets to precache.

## Gotchas

- A service worker has no effect on a first visit, and a cache-first worker can keep serving an old build. Version the cache name (SvelteKit's `version`) and delete old caches on `activate`.
- Precaching every built file downloads routes the visitor may never open.
- The generic `vite-plugin-pwa` works in any Vite build but is built around a static `index.html`. An SSR app still has to wire the navigation fallback by hand, so it is credited only where a framework-specific package exists (`@vite-pwa/nuxt`, `@vite-pwa/astro`).
- Service workers need HTTPS (or `localhost`), and most integrations disable them in dev.

## Labels

| Framework | Label | Points |
| --- | --- | --- |
| [Next](https://framework-compare.vercel.app/frameworks/next.md) | Third-party | 1 |
| [Nuxt](https://framework-compare.vercel.app/frameworks/nuxt.md) | Third-party | 1 |
| [SvelteKit](https://framework-compare.vercel.app/frameworks/sveltekit.md) | 1st-party | 2 |
| [SolidStart](https://framework-compare.vercel.app/frameworks/solidstart.md) | Manual | 0 |
| [TanStack Start (React)](https://framework-compare.vercel.app/frameworks/tanstack-start-react.md) | Manual | 0 |
| [TanStack Start (Solid)](https://framework-compare.vercel.app/frameworks/tanstack-start-solid.md) | Manual | 0 |
| [Pracht](https://framework-compare.vercel.app/frameworks/pracht.md) | Manual | 0 |
| [Waku](https://framework-compare.vercel.app/frameworks/waku.md) | Manual | 0 |
| [Ember](https://framework-compare.vercel.app/frameworks/ember.md) | Manual | 0 |
| [Astro](https://framework-compare.vercel.app/frameworks/astro.md) | Third-party | 1 |
| [React Router](https://framework-compare.vercel.app/frameworks/react-router.md) | Manual | 0 |
| [Qwik City](https://framework-compare.vercel.app/frameworks/qwik-city.md) | Experimental | 1 |
| [Angular (SSR)](https://framework-compare.vercel.app/frameworks/angular.md) | 1st-party | 2 |
| [Marko](https://framework-compare.vercel.app/frameworks/marko.md) | Manual | 0 |
| [Fresh](https://framework-compare.vercel.app/frameworks/fresh.md) | Manual | 0 |
| [Analog](https://framework-compare.vercel.app/frameworks/analog.md) | Manual | 0 |
| [Vike](https://framework-compare.vercel.app/frameworks/vike.md) | Manual | 0 |
| [RedwoodSDK](https://framework-compare.vercel.app/frameworks/redwoodsdk.md) | Manual | 0 |
| [Remix 3](https://framework-compare.vercel.app/frameworks/remix.md) | Manual | 0 |
| [Void (React)](https://framework-compare.vercel.app/frameworks/void-react.md) | Manual | 0 |
| [Void (Vue)](https://framework-compare.vercel.app/frameworks/void-vue.md) | Manual | 0 |
| [Void (Svelte)](https://framework-compare.vercel.app/frameworks/void-svelte.md) | Manual | 0 |
| [Void (Solid)](https://framework-compare.vercel.app/frameworks/void-solid.md) | Manual | 0 |

## How to enable it in each framework

### Next

Label: **Third-party** (1 of 2 points).

Next has no service worker build step. Its [PWA guide](https://nextjs.org/docs/app/guides/progressive-web-apps) hand-writes `public/sw.js` for push notifications and names the community [Serwist](https://serwist.pages.dev/docs/next) package for offline caching. `@serwist/next` wraps the Next config, compiles your worker, and injects the precache list. Next's own experimental `useOffline` hook retries failed navigations once the network returns; it is not a service worker.

```js
import withSerwistInit from "@serwist/next";

const withSerwist = withSerwistInit({
  swSrc: "app/sw.ts",
  swDest: "public/sw.js",
});

export default withSerwist({
  // Your Next.js config
});
```

*Adapted from [the Serwist getting-started guide](https://serwist.pages.dev/docs/next/getting-started) (revision and offline-fallback entries omitted).*

### Nuxt

Label: **Third-party** (1 of 2 points).

Add the community [`@vite-pwa/nuxt`](https://vite-pwa-org.netlify.app/frameworks/nuxt) module (listed in the [Nuxt modules directory](https://nuxt.com/modules/vite-pwa-nuxt)). It generates the service worker and the precache manifest with Workbox and registers it.

```ts
export default defineNuxtConfig({
  modules: ['@vite-pwa/nuxt'],
  pwa: {
    /* PWA options */
  },
})
```

*From [the Vite PWA Nuxt docs](https://vite-pwa-org.netlify.app/frameworks/nuxt).*

### SvelteKit

Label: **1st-party** (2 of 2 points).

Create `src/service-worker.js` (or `src/service-worker/index.ts`). SvelteKit bundles it and registers it automatically, and the [`$service-worker`](https://svelte.dev/docs/kit/service-workers) module gives it the built files, the static files, and a version string.

```js
import { build, files, version } from '$service-worker';

const CACHE = `cache-${version}`;
const ASSETS = [...build, ...files];
```

*Adapted from [the SvelteKit service workers docs](https://svelte.dev/docs/kit/service-workers) (the `install`, `activate`, and `fetch` handlers that use these are omitted).*

### SolidStart

Label: **Manual** (0 of 2 points).

No service worker support is documented. Put a hand-written `sw.js` in `public/` ([styling and assets](https://docs.solidjs.com/building-apps/styling-and-assets)) and register it yourself; the worker has no list of built assets unless you generate one.

Example of building it yourself:

Put a hand-written worker in `public/` and register it with an inline script in the document, next to the theme script.

```js
// public/sw.js
const CACHE = 'books-v1'; // change the name on each deploy

self.addEventListener('activate', (event) => {
  event.waitUntil(
    caches.keys().then((keys) => Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k)))),
  );
});

self.addEventListener('fetch', (event) => {
  const { request } = event;
  if (request.method !== 'GET' || new URL(request.url).origin !== location.origin) return;
  // Network first, so pages stay current. The cached copy answers when offline.
  event.respondWith(
    fetch(request)
      .then((response) => {
        const copy = response.clone();
        caches.open(CACHE).then((cache) => cache.put(request, copy));
        return response;
      })
      .catch(() => caches.match(request)),
  );
});
```

```tsx
// src/Document.tsx
const swScript = `if('serviceWorker' in navigator)addEventListener('load',function(){navigator.serviceWorker.register('/sw.js')});`;
// …
        <script>{themeScript}</script>
        <script>{swScript}</script>
```

Source: [Using Service Workers (MDN)](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers) · [SolidStart styling and assets](https://docs.solidjs.com/building-apps/styling-and-assets)

### TanStack Start (React)

Label: **Manual** (0 of 2 points).

No service worker or offline guide exists in the [TanStack Start docs](https://tanstack.com/start/latest/docs/framework/react/overview). Hand-write the worker and register it from the root route.

Example of building it yourself:

Put a hand-written worker in `public/` and register it with an inline script from the root route's `head`.

```js
// public/sw.js
const CACHE = 'books-v1'; // change the name on each deploy

self.addEventListener('activate', (event) => {
  event.waitUntil(
    caches.keys().then((keys) => Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k)))),
  );
});

self.addEventListener('fetch', (event) => {
  const { request } = event;
  if (request.method !== 'GET' || new URL(request.url).origin !== location.origin) return;
  // Network first, so pages stay current. The cached copy answers when offline.
  event.respondWith(
    fetch(request)
      .then((response) => {
        const copy = response.clone();
        caches.open(CACHE).then((cache) => cache.put(request, copy));
        return response;
      })
      .catch(() => caches.match(request)),
  );
});
```

```tsx
// src/routes/__root.tsx
const swScript = `if('serviceWorker' in navigator)addEventListener('load',function(){navigator.serviceWorker.register('/sw.js')});`;
// …
    scripts: [{ children: themeScript }, { children: swScript }],
```

Source: [Using Service Workers (MDN)](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers) · [TanStack Start document head](https://tanstack.com/router/latest/docs/framework/react/guide/document-head-management)

### TanStack Start (Solid)

Label: **Manual** (0 of 2 points).

The same: nothing in the [Solid variant's docs](https://tanstack.com/start/latest/docs/framework/solid/overview).

Example of building it yourself:

Put a hand-written worker in `public/` and register it with an inline script from the root route's `head`.

```js
// public/sw.js
const CACHE = 'books-v1'; // change the name on each deploy

self.addEventListener('activate', (event) => {
  event.waitUntil(
    caches.keys().then((keys) => Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k)))),
  );
});

self.addEventListener('fetch', (event) => {
  const { request } = event;
  if (request.method !== 'GET' || new URL(request.url).origin !== location.origin) return;
  // Network first, so pages stay current. The cached copy answers when offline.
  event.respondWith(
    fetch(request)
      .then((response) => {
        const copy = response.clone();
        caches.open(CACHE).then((cache) => cache.put(request, copy));
        return response;
      })
      .catch(() => caches.match(request)),
  );
});
```

```tsx
// src/routes/__root.tsx
const swScript = `if('serviceWorker' in navigator)addEventListener('load',function(){navigator.serviceWorker.register('/sw.js')});`;
// …
    scripts: [{ children: themeScript }, { children: swScript }],
```

Source: [Using Service Workers (MDN)](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers) · [TanStack Start document head](https://tanstack.com/router/latest/docs/framework/solid/guide/document-head-management)

### Pracht

Label: **Manual** (0 of 2 points).

No service worker support is documented in the [Pracht docs](https://pracht.resynapse.dev/docs/performance). Hand-write the worker, serve it from `public/`, and register it from the shell.

Example of building it yourself:

Put a hand-written worker in `public/` and register it with an inline script from the shell's `head()`.

```js
// public/sw.js
const CACHE = 'books-v1'; // change the name on each deploy

self.addEventListener('activate', (event) => {
  event.waitUntil(
    caches.keys().then((keys) => Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k)))),
  );
});

self.addEventListener('fetch', (event) => {
  const { request } = event;
  if (request.method !== 'GET' || new URL(request.url).origin !== location.origin) return;
  // Network first, so pages stay current. The cached copy answers when offline.
  event.respondWith(
    fetch(request)
      .then((response) => {
        const copy = response.clone();
        caches.open(CACHE).then((cache) => cache.put(request, copy));
        return response;
      })
      .catch(() => caches.match(request)),
  );
});
```

```tsx
// src/shells/public.tsx
const swScript = `if('serviceWorker' in navigator)addEventListener('load',function(){navigator.serviceWorker.register('/sw.js')});`;
// … in the shell's head()
    script: [{ children: themeScript }, { children: swScript }],
```

Source: [Using Service Workers (MDN)](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers) · [Pracht shells](https://pracht.resynapse.dev/docs/shells)

### Waku

Label: **Manual** (0 of 2 points).

No service worker support is documented. Put a hand-written worker in the [`public` folder](https://waku.gg/#static-assets) and register it from a client component.

Example of building it yourself:

Put a hand-written worker in `public/` and register it with an inline script in the root layout.

```js
// public/sw.js
const CACHE = 'books-v1'; // change the name on each deploy

self.addEventListener('activate', (event) => {
  event.waitUntil(
    caches.keys().then((keys) => Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k)))),
  );
});

self.addEventListener('fetch', (event) => {
  const { request } = event;
  if (request.method !== 'GET' || new URL(request.url).origin !== location.origin) return;
  // Network first, so pages stay current. The cached copy answers when offline.
  event.respondWith(
    fetch(request)
      .then((response) => {
        const copy = response.clone();
        caches.open(CACHE).then((cache) => cache.put(request, copy));
        return response;
      })
      .catch(() => caches.match(request)),
  );
});
```

```tsx
// src/pages/_layout.tsx
const swScript = `if('serviceWorker' in navigator)addEventListener('load',function(){navigator.serviceWorker.register('/sw.js')});`;
// … inside RootLayout
      <script dangerouslySetInnerHTML={{ __html: swScript }} />
```

Source: [Using Service Workers (MDN)](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers) · [Waku static assets](https://waku.gg/#static-assets)

### Ember

Label: **Manual** (0 of 2 points).

No first-party service worker is documented in the [Ember guides](https://guides.emberjs.com/release/). The community [`ember-service-worker`](https://github.com/DockYard/ember-service-worker) addon was last published in 2020 (9.0.1) and plugs into the classic Ember CLI build, which this Vite port does not use.

Example of building it yourself:

Put a hand-written worker in `public/` and register it with an inline script in `index.html`.

```js
// public/sw.js
const CACHE = 'books-v1'; // change the name on each deploy

self.addEventListener('activate', (event) => {
  event.waitUntil(
    caches.keys().then((keys) => Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k)))),
  );
});

self.addEventListener('fetch', (event) => {
  const { request } = event;
  if (request.method !== 'GET' || new URL(request.url).origin !== location.origin) return;
  // Network first, so pages stay current. The cached copy answers when offline.
  event.respondWith(
    fetch(request)
      .then((response) => {
        const copy = response.clone();
        caches.open(CACHE).then((cache) => cache.put(request, copy));
        return response;
      })
      .catch(() => caches.match(request)),
  );
});
```

```html
<!-- index.html, before </head> -->
<script>
  if ('serviceWorker' in navigator) {
    addEventListener('load', () => navigator.serviceWorker.register('/sw.js'));
  }
</script>
```

Source: [Using Service Workers (MDN)](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers)

### Astro

Label: **Third-party** (1 of 2 points).

No first-party service worker documented. The community `@vite-pwa/astro` integration (2.0.4) generates the worker and precache manifest with Workbox and registers it; the Astro docs do not mention it. ([vite-pwa astro](https://vite-pwa-org.netlify.app/frameworks/astro))

Example of building it yourself:

Add the `@vite-pwa/astro` integration, which generates a Workbox worker and precache manifest at build time. Register it from the main layout.

```js
// astro.config.mjs (npm install -D @vite-pwa/astro)
import { defineConfig } from "astro/config";
import AstroPWA from "@vite-pwa/astro";

export default defineConfig({
  integrations: [AstroPWA({ workbox: { navigateFallback: "/404" } })],
});
```

```astro
---
// src/layouts/Layout.astro
import { pwaInfo } from "virtual:pwa-info";
---
<head>
  <script src="/src/pwa.ts"></script>
  {pwaInfo && <Fragment set:html={pwaInfo.webManifest.linkTag} />}
</head>
```

```ts
// src/pwa.ts
import { registerSW } from "virtual:pwa-register";
registerSW({ immediate: true });
```

Source: [Vite PWA: Astro](https://vite-pwa-org.netlify.app/frameworks/astro)

### React Router

Label: **Manual** (0 of 2 points).

No service worker support documented. The community `@vite-pwa/remix` package (0.2.0, published 2025-03-30) targets Remix and does not state React Router v8 support, so it is not credited. Hand-write the worker in `public/` and register it. ([vite-pwa remix](https://vite-pwa-org.netlify.app/frameworks/remix))

Example of building it yourself:

Put a hand-written worker in `public/` and register it with an inline script in the root route.

```js
// public/sw.js
const CACHE = 'books-v1'; // change the name on each deploy

self.addEventListener('activate', (event) => {
  event.waitUntil(
    caches.keys().then((keys) => Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k)))),
  );
});

self.addEventListener('fetch', (event) => {
  const { request } = event;
  if (request.method !== 'GET' || new URL(request.url).origin !== location.origin) return;
  // Network first, so pages stay current. The cached copy answers when offline.
  event.respondWith(
    fetch(request)
      .then((response) => {
        const copy = response.clone();
        caches.open(CACHE).then((cache) => cache.put(request, copy));
        return response;
      })
      .catch(() => caches.match(request)),
  );
});
```

```tsx
// app/root.tsx
const swScript = `if('serviceWorker' in navigator)addEventListener('load',function(){navigator.serviceWorker.register('/sw.js')});`;
// … in <head>
        <script dangerouslySetInnerHTML={{ __html: swScript }} />
```

Source: [Using Service Workers (MDN)](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers)

### Qwik City

Label: **Experimental** (1 of 2 points).

`@qwikdev/pwa` (0.0.4, published 2024-02-26 from the QwikDev org) adds a `qwikPwa()` Vite plugin and a `setupPwa()` call in `src/routes/service-worker.ts` that precaches built assets; its README says it is in its early stages, and qwik.dev does not document it. Qwik's own service worker only prefetched bundles and the preloader has replaced it. ([QwikDev/pwa](https://github.com/QwikDev/pwa), [bundle](https://qwik.dev/docs/guides/bundle/))

Example of building it yourself:

`@qwikdev/pwa` adds a `qwikPwa()` Vite plugin and a `setupPwa()` call in the service worker route. It precaches the built `q-*.js` files, images and `public/` assets.

```ts
// vite.config.ts (npm install -D @qwikdev/pwa)
import { qwikPwa } from '@qwikdev/pwa'
// …
plugins: [qwikCity(), qwikVite(), qwikPwa()],
```

```ts
// src/routes/service-worker.ts
import { setupServiceWorker } from '@builder.io/qwik-city/service-worker'
import { setupPwa } from '@qwikdev/pwa/sw'

setupServiceWorker()
setupPwa()
```

Source: [QwikDev/pwa README](https://github.com/QwikDev/pwa)

### Angular (SSR)

Label: **1st-party** (2 of 2 points).

`ng add @angular/pwa` adds `@angular/service-worker`, registers it, and creates `ngsw-config.json`; the build writes the hashed asset manifest, and the worker caches the app shell and configured data groups. ([getting-started](https://angular.dev/ecosystem/service-workers/getting-started), [service-workers](https://angular.dev/ecosystem/service-workers))

Example of building it yourself:

`ng add @angular/pwa` adds `@angular/service-worker`, registers it in the app config and creates `ngsw-config.json`. The build writes the asset manifest the worker uses.

```ts
// src/app/app.config.ts
import { ApplicationConfig, isDevMode } from '@angular/core';
import { provideServiceWorker } from '@angular/service-worker';

export const appConfig: ApplicationConfig = {
  providers: [
    provideServiceWorker('ngsw-worker.js', {
      enabled: !isDevMode(),
      registrationStrategy: 'registerWhenStable:30000',
    }),
  ],
};
```

```json
// ngsw-config.json
{
  "index": "/index.html",
  "assetGroups": [
    { "name": "app", "installMode": "prefetch",
      "resources": { "files": ["/favicon.ico", "/index.html", "/*.css", "/*.js"] } }
  ],
  "dataGroups": [
    { "name": "api", "urls": ["/api/**"],
      "cacheConfig": { "strategy": "performance", "maxSize": 100, "maxAge": "1d" } }
  ]
}
```

Source: [Angular: Getting started with service workers](https://angular.dev/ecosystem/service-workers/getting-started), [Angular: Service worker configuration](https://angular.dev/ecosystem/service-workers/config)

### Marko

Label: **Manual** (0 of 2 points).

No service worker support documented in the Marko or Marko Run docs. Hand-write the worker, serve it as a static file, and register it from a `<script>`. ([file-based-routing](https://markojs.com/docs/marko-run/file-based-routing))

Example of building it yourself:

Put a hand-written worker in `public/` and register it with an inline script in the root layout.

```js
// public/sw.js
const CACHE = 'books-v1'; // change the name on each deploy

self.addEventListener('activate', (event) => {
  event.waitUntil(
    caches.keys().then((keys) => Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k)))),
  );
});

self.addEventListener('fetch', (event) => {
  const { request } = event;
  if (request.method !== 'GET' || new URL(request.url).origin !== location.origin) return;
  // Network first, so pages stay current. The cached copy answers when offline.
  event.respondWith(
    fetch(request)
      .then((response) => {
        const copy = response.clone();
        caches.open(CACHE).then((cache) => cache.put(request, copy));
        return response;
      })
      .catch(() => caches.match(request)),
  );
});
```

```marko
// src/routes/+layout.marko
static const SW_SCRIPT = `if('serviceWorker' in navigator)addEventListener('load',function(){navigator.serviceWorker.register('/sw.js')});`;
// … in <head>
    <html-script>$!{SW_SCRIPT}</html-script>
```

Source: [Using Service Workers (MDN)](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers)

### Fresh

Label: **Manual** (0 of 2 points).

No service worker support documented. Put a hand-written worker in `static/` and register it from an island. ([static-files](https://usefresh.dev/docs/concepts/static-files))

Example of building it yourself:

Put a hand-written worker in `static/` and register it with an inline script in the app wrapper.

```js
// static/sw.js
const CACHE = 'books-v1'; // change the name on each deploy

self.addEventListener('activate', (event) => {
  event.waitUntil(
    caches.keys().then((keys) => Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k)))),
  );
});

self.addEventListener('fetch', (event) => {
  const { request } = event;
  if (request.method !== 'GET' || new URL(request.url).origin !== location.origin) return;
  // Network first, so pages stay current. The cached copy answers when offline.
  event.respondWith(
    fetch(request)
      .then((response) => {
        const copy = response.clone();
        caches.open(CACHE).then((cache) => cache.put(request, copy));
        return response;
      })
      .catch(() => caches.match(request)),
  );
});
```

```tsx
// routes/_app.tsx
const swScript = `if('serviceWorker' in navigator)addEventListener('load',function(){navigator.serviceWorker.register('/sw.js')});`;
// … in <head>
        <script dangerouslySetInnerHTML={{ __html: swScript }} />
```

Source: [Using Service Workers (MDN)](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers) · [Fresh static files](https://usefresh.dev/docs/concepts/static-files)

### Analog

Label: **Manual** (0 of 2 points).

No service worker support documented in the Analog docs. Angular's `ng add @angular/pwa` "enables service worker build support in the CLI", and Analog replaces the Angular CLI build with Vite, so the `ngsw.json` asset manifest is not generated for you. Hand-write the worker and register it. ([angular service workers](https://angular.dev/ecosystem/service-workers/getting-started), [migrating](https://analogjs.org/docs/guides/migrating))

Example of building it yourself:

Put a hand-written worker in `public/` and register it with an inline script in `index.html`.

```js
// public/sw.js
const CACHE = 'books-v1'; // change the name on each deploy

self.addEventListener('activate', (event) => {
  event.waitUntil(
    caches.keys().then((keys) => Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k)))),
  );
});

self.addEventListener('fetch', (event) => {
  const { request } = event;
  if (request.method !== 'GET' || new URL(request.url).origin !== location.origin) return;
  // Network first, so pages stay current. The cached copy answers when offline.
  event.respondWith(
    fetch(request)
      .then((response) => {
        const copy = response.clone();
        caches.open(CACHE).then((cache) => cache.put(request, copy));
        return response;
      })
      .catch(() => caches.match(request)),
  );
});
```

```html
<!-- index.html, before </head> -->
<script>
  if ('serviceWorker' in navigator) {
    addEventListener('load', () => navigator.serviceWorker.register('/sw.js'));
  }
</script>
```

Source: [Using Service Workers (MDN)](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers)

### Vike

Label: **Manual** (0 of 2 points).

No service worker support documented in the Vike docs or its extension list. Hand-write the worker, serve it from `public/`, and register it from `+client.js`. ([static-directory](https://vike.dev/static-directory), [extensions](https://vike.dev/extensions))

Example of building it yourself:

Write the worker in `public/sw.js`, which Vite serves at `/sw.js`. Register it from `+client.ts`.

```js
// public/sw.js
const CACHE = 'v1'
self.addEventListener('fetch', (event) => {
  if (event.request.method !== 'GET') return
  event.respondWith(
    caches.match(event.request).then((hit) =>
      hit ?? fetch(event.request).then((res) => {
        caches.open(CACHE).then((c) => c.put(event.request, res.clone()))
        return res
      }),
    ),
  )
})
```

```ts
// pages/+client.ts
if ('serviceWorker' in navigator) {
  addEventListener('load', () => navigator.serviceWorker.register('/sw.js'))
}
```

Source: [Vike: Static directory](https://vike.dev/static-directory) · [MDN: Using Service Workers](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers)

### RedwoodSDK

Label: **Manual** (0 of 2 points).

No service worker support documented; the public assets guide shows only a `<link rel="manifest">` tag. Hand-write the worker in `public/` and register it from a client component. ([public-assets](https://docs.rwsdk.com/guides/frontend/public-assets))

Example of building it yourself:

Put a hand-written worker in `public/` and register it from a client component rendered on every page.

```js
// public/sw.js
const CACHE = "app-v1"; // change the name on each deploy

self.addEventListener("fetch", (event) => {
  const { request } = event;
  if (request.method !== "GET" || new URL(request.url).origin !== location.origin) return;
  // Network first, so pages stay current. The cached copy answers when offline.
  event.respondWith(
    fetch(request)
      .then((response) => {
        const copy = response.clone();
        caches.open(CACHE).then((cache) => cache.put(request, copy));
        return response;
      })
      .catch(() => caches.match(request)),
  );
});
```

```tsx
// src/app/components/RegisterServiceWorker.tsx
"use client";
import { useEffect } from "react";

export function RegisterServiceWorker() {
  useEffect(() => {
    if ("serviceWorker" in navigator) navigator.serviceWorker.register("/sw.js");
  }, []);
  return null;
}
```

Source: [Using Service Workers (MDN)](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers) · [RedwoodSDK: Public Assets](https://docs.rwsdk.com/guides/frontend/public-assets)

### Remix 3

Label: **Manual** (0 of 2 points).

No service worker support documented in the Remix 3 guides or API reference. Hand-write the worker, serve it through the asset server or a static route, and register it from a client entry. ([files-and-assets](https://docs.remix.run/files-and-assets/))

Example of building it yourself:

Write `sw.js` by hand, serve it from the root `public/` directory with `staticFiles()` so its scope is `/`, and register it from the browser entry.

```ts
// app/router.ts
export const router = createRouter({
  middleware: [staticFiles("./public", { index: false }), render({ assets })],
});

// app/actions/public/entry.ts
import { run } from "remix/component";

let app = run({ /* loadModule, … */ });
await app.ready();

if ("serviceWorker" in navigator) {
  navigator.serviceWorker.register("/sw.js");
}
```

Source: [Remix: Request handling, common middleware](https://docs.remix.run/request-handling/#common-middleware)

### Void (React)

Label: **Manual** (0 of 2 points).

No service worker support documented. Hand-write the worker, serve it from `public/`, and register it from client code. ([static-assets](https://void.cloud/guide/edge/static-assets))

Example of building it yourself:

Void has no service worker support. Put a hand-written worker in `public/` and register it from client code.

```ts
// src/register-sw.ts, imported from a client component
if ('serviceWorker' in navigator) {
  navigator.serviceWorker.register('/sw.js')
}
```

Source: [Void: Static assets](https://void.cloud/guide/edge/static-assets)

### Void (Vue)

Label: **Manual** (0 of 2 points).

No service worker support documented. Hand-write the worker, serve it from `public/`, and register it from client code. ([static-assets](https://void.cloud/guide/edge/static-assets))

Example of building it yourself:

Void has no service worker support. Put a hand-written worker in `public/` and register it from client code.

```ts
// src/register-sw.ts, imported from a client component
if ('serviceWorker' in navigator) {
  navigator.serviceWorker.register('/sw.js')
}
```

Source: [Void: Static assets](https://void.cloud/guide/edge/static-assets)

### Void (Svelte)

Label: **Manual** (0 of 2 points).

No service worker support documented. Hand-write the worker, serve it from `public/`, and register it from client code. ([static-assets](https://void.cloud/guide/edge/static-assets))

Example of building it yourself:

Void has no service worker support. Put a hand-written worker in `public/` and register it from client code.

```ts
// src/register-sw.ts, imported from a client component
if ('serviceWorker' in navigator) {
  navigator.serviceWorker.register('/sw.js')
}
```

Source: [Void: Static assets](https://void.cloud/guide/edge/static-assets)

### Void (Solid)

Label: **Manual** (0 of 2 points).

No service worker support documented. Hand-write the worker, serve it from `public/`, and register it from client code. ([static-assets](https://void.cloud/guide/edge/static-assets))

Example of building it yourself:

Void has no service worker support. Put a hand-written worker in `public/` and register it from client code.

```ts
// src/register-sw.ts, imported from a client component
if ('serviceWorker' in navigator) {
  navigator.serviceWorker.register('/sw.js')
}
```

Source: [Void: Static assets](https://void.cloud/guide/edge/static-assets)

---

HTML version: https://framework-compare.vercel.app/features/service-worker · All pages: https://framework-compare.vercel.app/llms.txt · Data: https://framework-compare.vercel.app/api/index.json
