Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including express-sse with all npm packages installed. Try it out:

var expressSse = require("express-sse")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

express-sse v0.5.1

An Express middleware for Server-Sent Events (EventSource)


npm version Build Status Code Climate codecov


An Express middleware for quick'n'easy server-sent events.


express-sse is meant to keep things simple. You need to send server-sent events without too many complications and fallbacks? This is the library to do so.


npm install --save express-sse


yarn add express-sse

Usage example:


You can pass an optional options object to the constructor. Currently it only supports changing the way initial data is treated. If you set isSerialized to false, the initial data is sent as a single event. The default value is true.

var sse = new SSE(["array", "containing", "initial", "content", "(optional)"], { isSerialized: false, initialEvent: 'optional initial event name' });


var SSE = require('express-sse');
var sse = new SSE(["array", "containing", "initial", "content", "(optional)"]);


app.get('/stream', sse.init);


sse.send(content, eventName);
sse.send(content, eventName, customID);
sse.updateInit(["array", "containing", "new", "content"]);
sse.serialize(["array", "to", "be", "sent", "as", "serialized", "events"]);


var es = new EventSource('/stream');

es.onmessage = function (event) {

es.addEventListener(eventName, function (event) {
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free