Registry / web-framework / susie
library1.2.8jsnpmunverified

Server-Sent Events plugin for hapi.js, allowing event streaming via h.event() with support for individual event objects and readable streams. Current stable version: 3.0.0. Works with Node >=8.9.0. Key differentiator: tight hapi integration, auto-stringification of objects, and automatic handling of reconnect via a built-in 'end' event. Ideal for real-time updates like notifications or live feeds.

npm install susie
INSTALL
IMPORT
SIG · SUSIE
S
susie
web-frameworkjavascriptv1.2.8
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
const susie = require('susie'); await server.register(susie);
const { susie } = require('susie');
Requires CommonJS, as susie is a hapi plugin. No default export for ESM.
h.event()
// Decorated on toolkit after registration handler: function (request, h) { return h.event({ data: 'hello' }); }
import { event } from 'susie';
h.event() is not a standalone import; it's added to the hapi response toolkit after registering the plugin.
plugin registration
await server.register({ plugin: require('susie'), options: {} });
server.register({ register: susie, options: {} });
Use the standard hapi plugin pattern. As of hapi v17+, registration must be awaited.

Registers the susie plugin and creates an SSE endpoint that sends 5 events with 1-second intervals, then closes the connection with an 'end' event.

const Hapi = require('@hapi/hapi'); const susie = require('susie'); const start = async () => { const server = Hapi.server({ port: 3000 }); await server.register(susie); server.route({ method: 'GET', path: '/events', handler: (request, h) => { const response = h.event({ id: 1, data: 'hello' }); let count = 1; const interval = setInterval(() => { count++; h.event({ id: count, data: `message ${count}` }); if (count >= 5) { clearInterval(interval); h.event(null); // sends 'end' event and closes } }, 1000); return response; } }); await server.start(); console.log('Server running on', server.info.uri); }; start();
Debug
Known issues
gotchaCalling h.event(null) sends a final event named 'end' before closing the response. The client must listen for this event and close the EventSource to prevent automatic reconnect.
fix
On the client, listen for the 'end' event and call source.close().
affects: >=1.0.0
gotchaObject mode streams: When passing a stream in objectMode, each chunk is JSON-stringified. Ensure client parses the data field as JSON if needed.
fix
On the client, use JSON.parse(event.data) if the data originated from an object.
affects: >=1.0.0
breakingv3 drops support for hapi v16 and earlier; requires @hapi/hapi v17+ (Node >=8.9.0).
fix
Upgrade to @hapi/hapi v17+ and use async/await for server registration.
affects: >=3.0.0 <4.0.0
deprecatedUsing require('susie') returns a plugin object; the old require('susie').plugin pattern is deprecated but still works.
fix
Use require('susie') directly in server.register().
affects: >=3.0.0
Errors
Common errors & fixes
Error: h.event is not a function
susie plugin not registered before route handler or incorrect registration.
fix
Ensure await server.register(require('susie')); is called before defining routes.
TypeError: Cannot destructure property 'susie' of ...
Using named import syntax with require or import on susie.
fix
Use const susie = require('susie'); and pass it directly to server.register.
Upgrade
Version history
1.2.8latest on npm
Audit
Dependencies
hapirequiredpeer dependency required for plugin registration and toolkit decoration
Agent activity
17 hits · last 30 days
node
14
OpenAI (training)
1
Resources
susie — npm install susie · libregistry