# LiveHtmlServer

> Documentation for Redweb 0.13.0. Install that exact version when following these examples.

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

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 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.

## Follow the example

This API pattern illustrates the named surface; it may require application-owned classes, credentials, or assets. Start from a complete recipe for a runnable application.

```tsx
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. HTTP rendering creates complete HTML and binds a stable page identity.
2. The generated live socket accepts only declared actions for that page.
3. State changes produce bounded updates while authentication and resource limits cover both transports.

## Options

- 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

## 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.

## What should I watch for?

Decide deliberately whether page state is per connection or shared. Authenticate both HTTP and upgrade paths with the same identity and cap render concurrency.
