@liebstoeckel/live-server
v0.3.6
Published
Live presenter and audience sync for liebstoeckel decks over Yjs and WebSocket.
Downloads
168
Maintainers
Readme
@liebstoeckel/live-server
Live presenter and audience sync for liebstoeckel.
Bun.serveplus Yjs over WebSocket on your LAN.
Part of liebstoeckel, a code-first presentation framework. You write decks in MDX and TSX and build them into a single self-contained HTML file with no server or runtime dependencies. The same file works offline, and when you host it the deck runs a live session between the presenter and the audience. Built on Bun, React 19, Motion, and Tailwind v4.
Status: experimental, pre-1.0. liebstoeckel is an evolving experiment, not yet production-ready. Before 1.0, breaking changes can land in any release without a major-version bump, so pin an exact version if you depend on it.
It serves a built deck and keeps everyone in step over WebSockets. The presenter drives navigation, the audience follows, and interactive plugins (polls, Q&A, reactions) share state through a Yjs document. Roles are handed out as unguessable URL tokens, so you open the presenter link yourself and hand the audience link to the room. Most people drive it through liebstoeckel live in @liebstoeckel/cli. Use this package directly when you want to embed the server.
Install
bun add @liebstoeckel/live-server
bun add yjs # peerBun-only, built on
Bun.serve.
Usage
import { startServer } from "@liebstoeckel/live-server";
const server = await startServer({ html: "dist/index.html" });
console.log(server.links.presenter); // open this yourself
console.log(server.links.viewer); // share this with the room
// …later
await server.stop();startServer({ html, port?, hostname? = "0.0.0.0", publicHost? }) resolves to a LiveServer with session, hub, port, baseUrl, links, serverPlugins, and stop(). It serves GET /?t=<token> and a WS /sync?t=<token> endpoint.
Exports
| Entry | What |
|---|---|
| @liebstoeckel/live-server | startServer, lanAddress, session helpers (createSession, roleForToken, buildLinks), the Hub / Peer runtime, injectBootstrap, deck loaders (classifyTargetPath, loadDeckHtml), the manifest/discovery and relay-client helpers, and the ServeOptions / LiveServer / Session / Role / Links types |
| @liebstoeckel/live-server/cli | runLive (powers liebstoeckel live) |
Gotchas
- Roles are URL tokens, not logins. Anyone with the presenter link can drive the deck, so treat it like a secret.
- It runs server-plugin code on the host and binds
0.0.0.0by default, so only serve decks you trust on a network you trust. - To share beyond the LAN, pair it with @liebstoeckel/present-relay.
Architecture
A Bun.serve HTTP and WebSocket server in front of a single-session Yjs relay. One deck is one process.
server.tsholdsstartServer. It extracts the embedded plugin manifest, then rehydrates and runs any server plugins on the host (a plugin's default export gets{ doc, session }and may return a teardown). It servesGET /?t=<token>(the deck HTML with the live bootstrap injected) and upgradesWS /sync?t=<token>. Inbound frames are capped at 4 MB, and Bun's auto-pingidleTimeoutprunes dead sockets.relay.tsholds theHub, which owns the authoritativeY.Doc. New peers get full state when they join (late-join replay), and each peer's update broadcasts to every other peer, keyed by origin. Periodic no-op keepalive frames feed the client liveness watchdogs and prune dead peers. A failing send drops that peer instead of throwing.session.tsmints two unguessable hex tokens per session.roleForTokenmaps a URL token topresenterorviewer, and denies anything unknown.buildLinksformats the shareable URLs.inject.tswriteswindow.__LIEBSTOECKEL_LIVE__into<head>(the WebSocket URL, role, token, and viewer link), so the engine's live client activates instead of its standalone fallback.manifest.tsanddiscovery.tsre-export@liebstoeckel/plugin-sdk(manifest extract and embed, plus server-bundle rehydrate), so the build and the live server share one implementation.relay-client.tsis the WAN path.uploadDeckandendSessioncall apresent-relaycontrol API, andrunServerPluginsViaRelayruns the deck's server plugins locally while connecting to the relay as the privilegedrunnerpeer, so deck code never runs on the relay.cli.tsholdsrunLive, which powersliebstoeckel live. It classifies the target (a built.htmlor a project directory, building through@liebstoeckel/enginewhen needed), then runs in LAN mode (startServer) or relay mode (relay-client), printing the local and LAN presenter and audience links.
Links
Licensed under MPL-2.0.
