Skip to main content
The live package provides low-latency real-time message delivery over WebSocket with topic-based publish/subscribe. It’s designed as a transport layer for instant updates: chat, notifications, collaborative editing, real-time dashboards, and more.

What is Real-time Communication?

In traditional HTTP, the browser sends a request and waits for a response. For new data, you must make another request (polling). Traditional HTTP:
With WebSockets, the connection stays open. Either side can send messages anytime. WebSocket:

Design Principles

Architecture

  1. Clients connect via WebSocket
  2. Sessions created for each connection
  3. Server subscribes sessions to topics
  4. Messages published to topics
  5. All subscribers receive the message

Core Concepts

Server

The Server manages WebSocket connections and pub/sub routing.

Session

A Session represents one WebSocket connection. Each has:
  • Unique ID
  • Optional value from authentication
  • Send queue for outgoing messages

Message

Messages have a topic and data:

Topics

Topics are named channels. Sessions subscribe to topics they care about. When you publish to a topic, all subscribers receive the message.

Quick Example

Server (Go):
Client (JavaScript):

When to Use Live

Use Live when:
  • You need instant updates (< 100ms latency)
  • Multiple clients need to see the same data
  • Building interactive features (chat, gaming)
  • Pushing data to clients (notifications)
Consider alternatives when:
  • Updates are infrequent (use polling or SSE)
  • You need message durability (use sync package)
  • Building a simple REST API

What’s Next?

  1. Quick Start - Build your first live feature
  2. Server - All server options explained
  3. Sessions - Connection lifecycle
  4. Pub/Sub - Topic patterns and publishing