Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Latest commit 5a49c2c @kljensen Merge pull request #1 from shesek/patch-1
Keep clientId in local closure
Failed to load latest commit information.
.gitignore Initial commit
Procfile Add procfile Flush out readme
app.js Keep clientId in local closure
package.json Get app working


This is a small example that shows how to do HTML5 Server Side Events with the express framework for node.js. HTML5 SSE is a great alternative to long-polling and WebSockets if you only need realtime communication from the server to the browser, rather than two-way.

Everything is contained in a single file: app.js. The app.js server will allow any number of browers to connect and, every 2 seconds, will broadcast out the same random number to all connected clients, who will receive that number over the HTML5 server side events "EventSource" API.


Clearly, you'll need to install node. Then you can do

git clone
cd node-sse-example
npm install

The last command will install the two dependencies, express and nodemon, which will allow you to watch a node script and restart it when it changes.


To run the app, you can do

node ./app.js

Or, if you want to edit the app and have the server automatically restart

./node_modules/.bin/nodemon ./app.js

assuming you've gone through the installation process as described above.

You should see output like the screenshot below, where there's three different browser windows all connected to the server. You can see they're each receiving the same data at the same time.

Browsers connected to server using HTML5 SSE

Something went wrong with that request. Please try again.