bc9a4da4db
Fixes #38613 Given `navigator.serviceWorker` [has ~96% support in browsers](https://caniuse.com/?search=navigator.serviceWorker), also removed the check for `"serviceWorker" in navigator`. ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm lint` - [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples) |
||
---|---|---|
.. | ||
pages | ||
public | ||
.gitignore | ||
next-env.d.ts | ||
package.json | ||
README.md | ||
tsconfig.json |
Service Worker Example
This example shows how to add a simple service worker to a Next.js application. The service worker is in public/sw.js
and it's installed by pages/_app.js
after the first render.
The example is based on the following blog post: Adding a service worker into your Next.js application.
Deploy your own
Deploy the example using Vercel:
How to use
Execute create-next-app
with npm, Yarn, or pnpm to bootstrap the example:
npx create-next-app --example with-service-worker with-service-worker-app
# or
yarn create next-app --example with-service-worker with-service-worker-app
# or
pnpm create next-app --example with-service-worker with-service-worker-app
Deploy it to the cloud with Vercel (Documentation).