Getting Started with Dialogue
This guide covers installation, basic setup, and your first real-time application using Dialogue.
1. Overview
Dialogue is an event-based realtime communication library built on Socket.IO, Hono, and Bun. It provides a simple, type-safe API for building real-time applications like chat, notifications, live dashboards, multiplayer games, and IoT systems.
1.1 Key Features
- Config-first with dynamic rooms: Define common rooms upfront, create others at runtime
- Event-centric: Events are first-class citizens with optional Zod schema validation
- Type-safe: Full TypeScript support with inferred types from schemas
- Bounded rooms: Optional
maxSizefor predictable scaling - Unified mental model: Backend and frontend share similar APIs
2. Installation
Install Dialogue and zod:
Dialogue requires Bun runtime for the backend server.
3. Quick Start
3.1 Define Events
Create a configuration file to define your events and rooms:
Dynamic Room Creation
While config-first is recommended, you can also create rooms dynamically at runtime:
Recommendation: Use predefined rooms for ~80% of your use cases (known room types), and dynamic creation for ~20% (user-generated content, temporary sessions).
3.2 Start the Server
Run with Bun:
3.3 Trigger Events from Backend
You can trigger events from anywhere in your backend code:
3.4 Connect from Frontend
4. Project Structure
Here's the recommended structure for a Dialogue application:
This is a minimal, focused view showing only application code. The Dialogue library itself is installed as dependencies and doesn't appear in your project structure.
5. Next Steps
- Read the Configuration Guide for detailed configuration options
- Explore the Backend API for server-side features
- Learn about the Client API for frontend integration
- See Examples for complete use-case implementations
This documentation reflects the current implementation and is subject to evolution. Contributions and feedback are welcome.