No description or website provided.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.buildkite
.github
flow-typed
src
.codecov.yml
.eslintrc.js
.flowconfig
.gitignore
.npmrc
Dockerfile
LICENSE
README.md
docker-compose.yml
package.json
renovate.json
yarn.lock

README.md

fusion-plugin-service-worker

Build status

The Fusion plugin for Service Workers.

Out of the box provides default service worker for basic asset caching. Can be fully customized.


Installation

yarn add fusion-plugin-service-worker

Usage

Default Service Worker

To use the default service worker, your src/sw.js should look like this:

import {getHandlers} from "fusion-plugin-sw";

export default (assetInfo) => {
  const {onFetch, onInstall} = getHandlers(assetInfo);
  self.addEventListener("install", onInstall);
  self.addEventListener("fetch", onFetch);
}

Custom Service Worker

Customize the ServiceWorker by editing src/sw.js in your app.


Setup

// src/main.js
import App from 'fusion-react';
import ServiceWorker from 'fusion-plugin-service-worker';

app.register(ServiceWorker)

The browser will automatically register the default service worker on page load.