Progressive Web App demonstrating push notifications with encrypted payload
This app demonstrates the web-push-libs/web-push NodeJS library which facilitates sending web push notifications with encrypted payloads via a custom backend.
Demo the live application here
The client-side app is a simple static site rooted at docs/
. The
reason the site lives in the docs/
folder is because GitHub pages only allows
you to serve static pages from the root or docs/
folder — custom folders like
frontend/
or client/
are not supported.
git clone [email protected]:domfarolino/push-notifications.git
cp .env.example .env # Copy environment variable structure
npm install
npm start # Run the server
To run the server locally you must export the necessary environment variables.
Environment variables should appear in the .env
file, and below is an
explanation of what each variables is used for:
PORT
: Defines the port on which the server will run.VAPID_PUBLIC_KEY
: Defines the public key generated via node web-push generate-vapid-keys
VAPID_PRIVATE_KEY
: Defines the private key generated via node web-push generate-vapid-keys
MONGO_URL
: Push notification credentials generated by the client are persisted in MongoDB. Use your mongo URL to save client-generated credentials.API_KEY
: Used to secure some routes local to this application, such as /credentials
.When running the server locally, be sure to update this.backendURL
in
docs/js/main.js
to point to your local server.