Skip to main content
The live template combines server-rendered views with WebSocket-powered real-time updates. This structure allows the server to push changes to the browser instantly, without the user needing to refresh. It’s like having a constant conversation between your server and the browser.

Directory Layout

Core Files

app/server/app.go

app/server/routes.go

handler/counter.go

assets/js/live.js

views/pages/counter.html

Message Flow

  1. Page Load - Server renders initial HTML
  2. WebSocket Connect - Client connects to /ws
  3. User Action - Button click calls live.send()
  4. Server Receives - OnMessage handler processes
  5. Server Sends - New HTML sent back
  6. DOM Update - Client replaces content

Next Steps

Tutorial

Build a real-time chat

Live Docs

Deep dive into live views