This example demonstrates how to add push notifications to an app using Serwist with Next.js.
-
Init the project
cd examples/next-web-push
or
Execute
degit
with npm, Yarn, pnpm, or bun to bootstrap the example:npx degit serwist/serwist/examples/next-web-push my-app
yarn degit serwist/serwist/examples/next-web-push my-app
pnpx degit serwist/serwist/examples/next-web-push my-app
bunx degit serwist/serwist/examples/next-web-push my-app
-
Run
pnpm web-push generate-vapid-keys --json
-
Create a
.env
file, and put the keys generated from the previous steps[email protected] WEB_PUSH_PRIVATE_KEY=<vapid-private-key> NEXT_PUBLIC_WEB_PUSH_PUBLIC_KEY=<vapid-public-key>
-
Build and start
pnpm build pnpm start
**/public/sw**
**/public/swe**