This example demonstrates how LiveTemplate supports progressive enhancement - allowing apps to work both with and without JavaScript enabled.
Forms work in both modes using standard HTML with method="POST" and button name routing:
<form method="POST" name="add">
<input type="text" name="title">
<button type="submit" name="add">Add</button>
</form>
For non-JS clients, successful actions redirect using HTTP 303:
This prevents duplicate submissions when users refresh the page.
When validation fails:
Success/error messages are shown once after actions:
# Development mode (uses local client library)
LVT_DEV_MODE=true go run .
# Production mode (uses CDN client library)
go run .
Visit http://localhost:8080 and try:
Progressive enhancement is enabled by default. To disable it:
// Via environment variable
LVT_PROGRESSIVE_ENHANCEMENT=false go run .
// Or via code
tmpl := livetemplate.New("app", livetemplate.WithProgressiveEnhancement(false))
main.go - Controller, state, and action handlersprogressive-enhancement.tmpl - Template with dual-mode formsprogressive_enhancement_test.go - End-to-end tests for progressive enhancement behaviorREADME.md - This documentation