This is a full-stack example showing:
Text tutorial: https://dev.to/marcushellberg/how-to-send-web-push-notifications-in-java-21lo Video tutorial: https://youtu.be/M5sbGvW3S4I
The project uses Hilla. It has a Spring Boot backend (Java) and a Lit frontend (TypeScript). It uses the Java WebPush library for sending messages.
npx web-push generate-vapid-keys
..env.template
to .env
and add your keys to it.source .env
mvn
or by running Application.java
.frontend/views/notifications/notifications-view.ts
contains the client implementation for subscribing and unsubscribingsrc/main/java/com/example/application/MessageService.java
contains the code for sending push messagessrc/main/java/com/example/application/MessageEndpoint.java
contains the code for accessing the server