ellie5-sdk
v0.0.3
Published
Browser SDK for connecting to the Ellie server via SSE.
Downloads
29
Readme
ellie5-sdk
Browser SDK for connecting to the Ellie server via SSE.
Install
bun add ellie5-sdkUsage
import { init } from "ellie5-sdk";
const client = init({
onOpen: () => console.log("connected"),
onMessage: (data) => console.log("event:", data),
onError: (err) => console.error("sse error", err),
});
// later
client.close();Tours (show_tour)
If the server sends an SSE message shaped like:
{ type: "show_tour", tour: /* ... */ }the SDK will auto-start the tour by default.
If the current page is not already on the tour’s startUrl (path match), the SDK will log a warning and do nothing (it will not navigate).
You can hook into this, or disable auto-start:
import { init, type Tour } from "ellie5-sdk";
init({
onShowTour: (tour: Tour) => {
console.log("received tour:", tour.id);
},
autoStartTours: true, // default
});
// or:
init({ autoStartTours: false });By default it connects to http://localhost:3001/api/sse. You can override:
init({ url: "https://your-server.example.com/api/sse" });