Masterclass by

Chargement de la formation
HomeOur trainingsDiscover Mercure
Discover Mercure

Discover Mercure

Mercure is a web protocol allowing to push data updates to web browsers (or other HTTP clients) in a convenient, fast, reliable and battery-efficient way. Mercure is especially useful to publish real-time updates of resources served through web APIs.


1 - Protocol presentation

Use case

  • Straight availibilty
  • Asynchronous uses
  • Collaborative building 

Differences and similarities between Mercure and existing protocols:

  • With Server-Sent Events
  • With Websocket
  • With Websub 
  • With Web Push

Presentation of HTTP/2 and its use with Mercure

Presentation of HTTP/3 and its use with Mercure

2 - Hub

  • Classical installation
  • Installation with Docker
  • Installation with Kubernetes
  • Automatic HTTP/2 and HTTPS support (using Let's Encrypt)
  • Configuration
  • Alternative implementation (Hub Node.js)

3 - Client side

  • JavaScript: EventSource class
  • Regards related to cross-domains cookies
  • Configure CORSs
  • Polyfill for old browser

4 - Authorization

  • Presentation of Mercure authorization mechanism
  • Presentation of JWT tokens format
  • Targets
  • Publication rights
  • Subscription rights
  • Authorization through cookies
  • Authorization through HTTP header

5 - Mercure and APIs

  • REST, HATEOAS and hypermedia reminders
  • Presentation of auto-discoverable through Web Linking
  • Use Mercure for GraphQL subscriptions

6 - Mercure integration with main frameworks and languages

  • Example with API Platform and Symfony (PHP, through Hub)
  • Example with Node.js (through Hub)
  • Use without hub with Go
  • Use without hub with Node.js

7 - End-to-end encryption