Live HTML · In depth

LiveHtmlServer

Lower-level server-rendered page host. Prefer defineApp({ pages, sockets }) and app.run() to compose a new application; LiveHtmlServer remains available for direct page-host lifecycle integration.

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 defineApp for the normal application entry point. Construct LiveHtmlServer directly only when you need to own its lower-level listener and shutdown behavior.

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
  • providers: explicit objects for @inject fields
  • uploadTimeoutMs: bounds an in-progress browser file action
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.