rsnext/examples/with-service-worker
Balázs Orbán bc9a4da4db
chore: update with-service-worker example (#38670)
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)
2022-07-18 20:01:49 +00:00
..
pages chore: update with-service-worker example (#38670) 2022-07-18 20:01:49 +00:00
public Example for adding a service worker into a next.js application (#17855) 2020-11-12 01:09:25 +00:00
.gitignore Example for adding a service worker into a next.js application (#17855) 2020-11-12 01:09:25 +00:00
next-env.d.ts chore: update with-service-worker example (#38670) 2022-07-18 20:01:49 +00:00
package.json chore: update with-service-worker example (#38670) 2022-07-18 20:01:49 +00:00
README.md Update pnpm create next-app for latest pnpm 6 and 7 (#37254) 2022-05-27 21:21:40 +00:00
tsconfig.json chore: update with-service-worker example (#38670) 2022-07-18 20:01:49 +00:00

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:

Deploy with 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).