Overview
Architecture
- Server-side state: All application state lives on the server
- Binary protocol: Efficient mutation streaming via WebSocket
- Low client overhead: Minimal JavaScript required
- Secure by default: No client-side logic to expose
Quick Start
Dependencies
Add LiveView with Axum support:Basic Server
Create a LiveView server:http://localhost:3000
LiveView Pool
The LiveView pool manages concurrent client connections:Server State
Per-Connection State
Each WebSocket connection gets its own VirtualDOM:Shared State
Share state across connections:Database Integration
Integrate with databases seamlessly:Real-time Updates
Push updates to connected clients:Authentication
Implement authentication:Performance
Connection Pooling
The LiveViewPool uses a thread pool:- Each client gets a pinned task
- VirtualDOM runs on task’s executor
- Efficient handling of concurrent clients
Binary Protocol
Mutations are sent as binary data:- Sledgehammer binary encoding
- Minimal overhead
- Efficient WebSocket usage
Backpressure
Handle slow clients:Scaling
Horizontal Scaling
Scale across multiple servers:Load Balancing
Use sticky sessions:Error Handling
Handle disconnections gracefully:Configuration
Customize LiveView behavior:Security
CSRF Protection
Rate Limiting
Debugging
Enable logging:Deployment
Docker
Systemd Service
Comparison with Other Platforms
| Feature | LiveView | Web | Desktop |
|---|---|---|---|
| State Location | Server | Client | Client |
| Network Required | Yes | Initial | No |
| Security | High | Medium | High |
| Scalability | Moderate | High | N/A |
| Latency | Network | None | None |
| Server Cost | Higher | Lower | None |
When to Use LiveView
LiveView is ideal for:- Internal admin dashboards
- Real-time collaborative tools
- Data-heavy applications
- Apps requiring server-side security
- Rapid prototyping
- Offline functionality is required
- Latency is critical
- Client-side resources are preferred
- Scaling to millions of users
Next Steps
- Fullstack - Combine client and server rendering
- Web Platform - Client-side WASM apps
- Authentication - Secure your application