@fluxstack/live-elysia
v0.5.0
Published
Elysia.js WebSocket transport adapter for @fluxstack/live (Bun runtime)
Maintainers
Readme
@fluxstack/live-elysia
Elysia transport adapter for @fluxstack/live.
Installation
bun add @fluxstack/live @fluxstack/live-elysia elysiaQuick Start
import { Elysia } from 'elysia'
import { LiveServer } from '@fluxstack/live'
import { ElysiaTransport } from '@fluxstack/live-elysia'
const app = new Elysia()
const server = new LiveServer({
transport: new ElysiaTransport(app),
componentsPath: './src/components',
})
await server.start()
app.listen(3000)How It Works
ElysiaTransport implements the LiveTransport interface from @fluxstack/live:
- WebSocket — Registers a WebSocket route at
/api/live/wsusing Elysia's nativews()plugin - HTTP Routes — Maps
GET/POST/PUT/DELETEmonitoring routes (e.g./api/live/stats) - Client Bundle — Serves the browser IIFE bundle at
/live-client.jsfor vanilla JS usage
All security logic (auth, rate limiting, state signing, payload sanitization) is handled by @fluxstack/live core — the transport adapter is a thin pass-through wrapper.
API
ElysiaTransport
import { ElysiaTransport } from '@fluxstack/live-elysia'
const transport = new ElysiaTransport(app)wrapElysiaWs()
Helper to wrap Elysia's ServerWebSocket into the generic GenericWebSocket interface:
import { wrapElysiaWs } from '@fluxstack/live-elysia'
const genericWs = wrapElysiaWs(elysiaWs)Requirements
- Elysia
>=1.0.0 - Bun runtime
License
MIT
