WebSocket Disabled Example

This example demonstrates LiveTemplate's WithWebSocketDisabled() mode. The client library is still included and handles all interactions — but uses HTTP fetch instead of WebSocket to send actions and receive tree-based DOM updates.

When to Use This Mode

How It Works

Client Library Still Active

The LiveTemplate client library is included and works the same as in WebSocket mode:

Detection

The client detects WebSocket availability by checking the X-LiveTemplate-WebSocket response header:

Progressive Enhancement

Forms use method="POST" with button name routing, so the app still works without JavaScript via the POST-Redirect-GET pattern.

Running

# Development mode (serves client library locally)
LVT_DEV_MODE=true go run .

Visit http://localhost:8080.

Files