Example applications demonstrating LiveTemplate usage with various features and patterns.
Directory: counter/
Basic counter demonstrating reactive state updates.
cd counter
go run main.go
# Visit http://localhost:8080Features:
- Simple state management
- Button click handling
- Real-time updates
Directory: chat/
Multi-user chat application with WebSocket communication.
cd chat
go run main.go
# Visit http://localhost:8080Features:
- Multi-user chat rooms
- WebSocket messaging
- User presence
- Message history
Directory: todos/
Complete todo list with database, validation, and full CRUD operations.
cd todos
go run main.go
# Visit http://localhost:8080Features:
- SQLite database
- CRUD operations
- Form validation
- Database migrations
- E2E tests with Chromedp
Directory: graceful-shutdown/
Demonstrates proper server shutdown handling.
cd graceful-shutdown
go run main.go
# Press Ctrl+C to trigger graceful shutdownFeatures:
- Signal handling
- Connection draining
- Cleanup procedures
Directory: observability/
Logging, metrics, and tracing example.
cd observability
go run main.goFeatures:
- Structured logging
- Custom metrics
- Request tracing
- Performance monitoring
Directory: testing/01_basic/
E2E testing patterns with Chromedp.
cd testing/01_basic
go test -vFeatures:
- Browser automation
- E2E test patterns
- Test helpers
- Assertions
Directory: production/single-host/
Production deployment configuration.
cd production/single-host
go run main.goFeatures:
- Production server setup
- Environment configuration
- Health checks
- Deployment best practices
Directory: trace-correlation/
Request tracing and correlation IDs.
cd trace-correlation
go run main.goFeatures:
- Trace ID generation
- Request correlation
- Distributed tracing
- Log correlation
Each example is self-contained with its own go.mod. To run an example:
cd <example-directory>
go mod download
go run main.goRun all working examples at once:
./test-all.shThis script will:
- Test all 5 working examples (counter, chat, todos, graceful-shutdown, testing)
- Skip disabled examples by default (use without
--skip-disabledto attempt them) - Show a summary of passed/failed/skipped tests
Examples include E2E tests using Chromedp:
cd <example-directory>
go test -vThe test script is also used in GitHub Actions. See .github/workflows/test.yml for CI configuration.
Examples are configured to use the CDN version of the client library:
<script src="https://cdn.jsdelivr.net/npm/@livetemplate/client@0.1.0/dist/livetemplate-client.browser.js"></script>For local development, examples can serve the client library locally using github.com/livetemplate/lvt/testing.
- Core Library:
github.com/livetemplate/livetemplate v0.1.0 - LVT Testing (for examples with E2E tests):
github.com/livetemplate/lvt v0.1.0 - Client Library:
@livetemplate/client@0.1.0(via CDN)
- LiveTemplate Core - Go library for server-side rendering
- Client Library - TypeScript client for browsers
- LVT CLI - Code generator and development server
Examples follow the LiveTemplate core library's major.minor version:
- Core:
v0.1.5→ Examples:v0.1.x(any patch version) - Core:
v0.2.0→ Examples:v0.2.0(must match major.minor)
See CONTRIBUTING.md for guidelines on adding new examples.
MIT License - see LICENSE for details.