Core Client APIs Overview

Navigate the Erebus PubSub client APIs organized by functionality

Core Client APIs Overview

The Erebus Core SDK provides comprehensive APIs for real-time messaging, presence tracking, and message history. This overview helps you navigate to the specific functionality you need.

📚 API Documentation Structure

Our API documentation is organized into focused sections for easier learning and reference:

SectionCoverageWhen to Use
Getting StartedBasic APIs + working examplesFirst-time SDK users
MessagingPublish/subscribe + historyBuilding real-time features
Connection ManagementLifecycle + error handlingProduction apps
Presence TrackingUser awareness APIsSocial features
Types ReferenceTypeScript definitionsType-safe development

🚀 Quick Navigation

New to Erebus?

Start with Getting Started with APIs for a practical walkthrough with working examples.

Building Real-Time Features?

Go to Messaging APIs for publish/subscribe patterns and message history.

Need Robust Connections?

Check Connection Management for lifecycle management and error handling.

Adding Social Features?

Visit Presence Tracking for user awareness and online status.

Working with TypeScript?

Reference Types Reference for complete type definitions.

💡 Quick Examples

Basic Usage

import { ErebusClient, ErebusClientState } from "@erebus-sh/sdk/client";

const client = ErebusClient.createClient({
  client: ErebusClientState.PubSub,
  authBaseUrl: "https://your-auth.com"
});

client.joinChannel("my-app");
await client.connect();
await client.subscribe("notifications", console.log);
await client.publish("notifications", "Hello!");

With Presence

// Track user activity
await client.onPresence("chat:room", (presence) => {
  console.log(`${presence.clientId} is ${presence.status}`);
});

With History

// Catch up on missed messages
const history = await client.getHistory("chat:room", {
  limit: 50,
  direction: "backward"
});

With Type Safety

import { ErebusPubSubSchemas } from "@erebus-sh/sdk/client";
import { z } from "zod";

const schemas = { chat: z.object({ text: z.string() }) };
const typed = new ErebusPubSubSchemas(client, schemas);

await typed.subscribe("chat", "room", (msg) => {
  console.log(msg.payload.text); // ✅ Fully typed
});


📖 Detailed API Documentation

The API documentation has been reorganized into focused sections for better navigation:

🏁 Getting Started with APIs

  • Complete working example with auth server setup
  • Step-by-step walkthrough of core APIs
  • Common use case patterns for chat, notifications, collaboration

📡 Messaging APIs

  • Publish/subscribe patterns with examples
  • Advanced subscription options and callbacks
  • Message history with pagination and iterators

🔌 Connection Management

  • Connection lifecycle and state monitoring
  • Error handling patterns and recovery strategies
  • Production best practices and monitoring

👥 Presence Tracking

  • User awareness APIs for online/offline status
  • Advanced presence patterns for typing indicators
  • Multi-topic presence management

📋 Types Reference

  • Complete TypeScript definitions for all APIs
  • Interface documentation with usage examples
  • Type guards and utility types

🎯 Quick API Examples

Basic Publish/Subscribe

// Simple messaging
await client.subscribe("notifications", (msg) => {
  console.log("📩", msg.payload);
});

await client.publish("notifications", "Hello World!");

With Acknowledgments

// Reliable delivery
await client.publishWithAck(
  "alerts",
  "System maintenance starting",
  (ack) => console.log("Delivered:", ack.success)
);

With Presence

// Track user activity
await client.onPresence("chat:room", (presence) => {
  updateUserList(presence.clientId, presence.status);
});

With History

// Load message history
const history = await client.getHistory("chat:room", { limit: 50 });
history.items.forEach(displayMessage);

ResourceDescription
Getting StartedComplete walkthrough with examples
Message HistoryAdvanced pagination guide
Schema ValidationType-safe messaging
ExamplesWorking applications