How laravel/echo works
Laravel Echo is a JavaScript client library for subscribing to broadcast channels and handling realtime events. The primary flow is an application configuring Echo, choosing a channel and event through a framework integration or Echo API, then receiving events through a broadcaster-specific connector and channel implementation. The repository also includes framework adapters for React, Svelte, and Vue, plus Mercure presence and private-channel support. Some implementation files were not sampled, so driver-specific internal calls are shown only where the index or excerpts support them.
Main entry points: echo.ts Echo API · channel Channel implementations · socketio-connector.ts Socket.IO connector · mercure-connector.ts Mercure connector
Components 19
Echo runtime
- Echo API
packages/laravel-echo/src/echo.ts - Connector base
packages/laravel-echo/src/connector/connector.ts - Channel implementations
packages/laravel-echo/src/channel - Presence channels
packages/laravel-echo/src/channel/presence-channel.ts - Event formatter
packages/laravel-echo/src/util/event-formatter.ts
Broadcast drivers
- Mercure connector
packages/laravel-echo/src/connector/mercure-connector.ts - Mercure presence
packages/laravel-echo/src/channel/mercure-presence-channel.ts - Pusher connector
packages/laravel-echo/src/connector/pusher-connector.ts - Socket.IO connector
packages/laravel-echo/src/connector/socketio-connector.ts - Socket.IO channel
packages/laravel-echo/src/channel/socketio-channel.ts - Socket.IO types
packages/laravel-echo/src/socketio-types.ts
React adapter
- Echo configuration
packages/react/src/config/index.ts - Realtime hooks
packages/react/src/hooks/use-echo.ts
Svelte adapter
- Echo configuration
packages/svelte/src/config/index.ts - Realtime runes
packages/svelte/src/runes/useEcho.ts
Vue adapter
- Echo configuration
packages/vue/src/config/index.ts - Realtime composables
packages/vue/src/composables/useEcho.ts
Other components
- Application
- WebSocket broadcaster
Connections 20
- Application → Echo API: configures and subscribes
- Echo API → Connector base: connects through
packages/laravel-echo/src/echo.ts - Echo API → Channel implementations: delegates channel access
packages/laravel-echo/src/echo.ts - Connector base → Channel implementations: defines channel contracts
packages/laravel-echo/src/connector/connector.ts - Channel implementations → Presence channels: extends channel behavior
packages/laravel-echo/src/channel/presence-channel.ts - Mercure connector → Channel implementations: imports channel implementations
packages/laravel-echo/src/connector/mercure-connector.ts - Pusher connector → Channel implementations: imports channel implementations
packages/laravel-echo/src/connector/pusher-connector.ts - Socket.IO connector → Channel implementations: imports channel implementations
packages/laravel-echo/src/connector/socketio-connector.ts - Socket.IO channel → Socket.IO types: uses types
packages/laravel-echo/src/channel/socketio-channel.ts - Socket.IO connector → Socket.IO types: uses types
packages/laravel-echo/src/connector/socketio-connector.ts - Mercure presence → Presence channels: implements presence behavior
packages/laravel-echo/src/channel/mercure-presence-channel.ts - Echo configuration → Echo API: constructs
packages/react/src/config/index.ts - Realtime hooks → Echo configuration: gets Echo instance
packages/react/src/hooks/use-echo.ts - Echo configuration → Echo API: constructs
packages/svelte/src/config/index.ts - Realtime runes → Echo configuration: gets Echo instance
packages/svelte/src/runes/useEcho.ts - Echo configuration → Echo API: constructs
packages/vue/src/config/index.ts - Realtime composables → Echo configuration: gets Echo instance
packages/vue/src/composables/useEcho.ts - Mercure connector → WebSocket broadcaster: communicates through
- Pusher connector → WebSocket broadcaster: communicates through
- Socket.IO connector → WebSocket broadcaster: communicates through