Live HTML · In depth

LiveHtmlServer

Decorator-first server rendering and realtime browser updates on Redweb’s existing HTTP and WebSocket stack. Pages can be connection-scoped or intentionally shared.

Explain it like I’m five

The simple mental model

LiveHtmlServer is a stage manager for server-rendered pages. It serves the first complete HTML scene, then carries approved actions backstage and sends updated pieces back.

When it fits

When should I use it?

Use it for decorator-first HTML applications that need server state and realtime interaction without React, hydration, or a separate client API layer.

A practical API pattern

Follow the example

This pattern explains the named API. Application classes, credentials, and assets may need to be supplied; use a complete recipe for a runnable starting point.

Read this article as Markdown

TypeScript
import { LiveHtmlServer } from 'redweb'
import { DocsPage, StatusPage } from './pages.js'

const server = new LiveHtmlServer({
  pages: [DocsPage, StatusPage],
  port: 8080,
  heartbeat: { intervalMs: 15_000, timeoutMs: 10_000 },
})
  1. 1

    HTTP rendering creates complete HTML and binds a stable page identity.

  2. 2

    The generated live socket accepts only declared actions for that page.

  3. 3

    State changes produce bounded updates while authentication and resource limits cover both transports.

Configuration

Choices you can make

  • pages: non-empty array of classes decorated with page()
  • templateRoot: optional root for colocated HTML and CSS assets
  • sessionTtlMs and maxSessions: bound pending and reconnectable sessions
  • maxConcurrentRenders: independent HTTP render concurrency ceiling
  • heartbeat: detects half-open browser connections
  • authenticate: binds HTTP renders and socket upgrades to one stable identity
  • origins: exact allowlist or asynchronous origin predicate
Surface area

Methods and members

constructor(options)

Builds the page renderer, HTTP routes, generated assets, and live WebSocket route on one listener.

shutdown()

Aborts active renders, drains routes, disposes pages and components, and closes owned resources.