Step 1: Create the Project
http://localhost:8080 to see the default app.
Step 2: Understand the Counter
The template includes a counter example. Let’s examine how it works.The Counter Handler
Look athandler/counter.go:
The Counter View
Look atviews/pages/counter.html:
The WebSocket Handler
Inapp/server/app.go, messages are handled:
Step 3: Test Real-Time Updates
- Open
http://localhost:8080/counterin one browser - Open it in another browser window
- Click + or - in one window
- Watch both windows update!
Step 4: Add a Reset Button
Update therenderCounter function:
Step 5: Add Per-User Counters
Each user can have their own counter:How Live Updates Work
What You Learned
- WebSocket connection handling
- Message-based communication
- Broadcasting updates to all clients
- Per-session state management
- Server-side rendering for updates
Next Steps
Sync Template
Add offline support and data sync
Live Documentation
Deep dive into live features