You can find here some examples of Node.js code to send data to a Mercure-Hub server.
These examples are designed to run with a Stackhero Mercure-Hub service. You'll more informations about Stackhero here:
First you have to create a Mercure Hub service on Stackhero.
In Stackhero's configuration, allow "anonymous subscribers" to let the client connect to topics without authentication.
In frontend/susbcriber.html, fill the endpoint (domain name of Stackhero's service).
Then open the file susbcriber.html in your browser.
Fill the configuration informations in backend/.env-example and rename the file to .env.
Then start the server with npm run start.
The back end code will send datas every seconds to the Mercure Hub, on a the topic /books/1.
The frond end will listen datas from the topic /books/1 and display them.
Congratulations, you have a Mercure Hub up and running! 🎉
