- Install
web-push
package globally on your system:
npm install web-push -g
- Generate vapid keys:
web-push generate-vapid-keys --json
- Setup the required environment variables:
VAPID_PUBLIC_KEY
VAPID_PRIVATE_KEY
VAPID_SUBJECT
- Start the server:
// Run the server/API
cd example
yarn install
yarn start:server
By default, the server is listening on port 8081
. You can change it by settting the environment variable PORT
to the desired value.
- Start the client:
// In another terminal, set the VAPID_PUBLIC_KEY environment variable and run the client app
cd example
yarn start:client
- Connect to
localhost:8080
By default, the client is listening on port 8080
. You can change it by settting the environment variable CLIENT_PORT
to the desired value.