Docs/Getting Started
Client Configuration
Pusher JS and Laravel Echo client configuration reference.
JavaScript / TypeScript (pusher-js)
Install the official client package:
bash
npm install pusher-jsCloud Configuration
ts
import Pusher from 'pusher-js'
const pusher = new Pusher('YOUR_APP_KEY', {
wsHost: 'wss.socketo.dev',
wssPort: 443,
forceTLS: true,
cluster: 'socketo',
enabledTransports: ['ws'],
channelAuthorization: {
endpoint: '/api/broadcasting/auth',
transport: 'ajax',
headers: {
Authorization: `Bearer ${userToken}`,
},
},
userAuthentication: {
endpoint: '/api/broadcasting/user-auth',
},
})Local CLI Configuration
ts
const pusher = new Pusher('local', {
wsHost: 'localhost',
wsPort: 8787,
forceTLS: false,
cluster: 'local',
enabledTransports: ['ws'],
})Laravel Echo
Install Echo and Pusher JS:
bash
npm install --save-dev laravel-echo pusher-jsEcho Initialization (resources/js/bootstrap.js)
js
import Echo from 'laravel-echo'
import Pusher from 'pusher-js'
window.Pusher = Pusher
window.Echo = new Echo({
broadcaster: 'pusher',
key: import.meta.env.VITE_SOCKETO_APP_KEY,
wsHost: import.meta.env.VITE_SOCKETO_HOST ?? 'wss.socketo.dev',
wssPort: Number(import.meta.env.VITE_SOCKETO_PORT ?? 443),
forceTLS: (import.meta.env.VITE_SOCKETO_SCHEME ?? 'https') === 'https',
cluster: 'socketo',
enabledTransports: ['ws'],
authEndpoint: '/broadcasting/auth',
})Environment Variables (.env)
env
VITE_SOCKETO_APP_KEY="your-app-key"
VITE_SOCKETO_HOST="wss.socketo.dev"
VITE_SOCKETO_PORT=443
VITE_SOCKETO_SCHEME="https"Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
wsHost | string | — | WebSocket domain address (wss.socketo.dev or localhost). |
wssPort | number | 443 | Secure TLS port (443). |
wsPort | number | 80 | Unencrypted development port (CLI default: 8787). |
forceTLS | boolean | true | Enforce WSS/TLS encryption. Set to false for local CLI development. |
cluster | string | 'socketo' | Routing cluster identifier ('socketo' or 'local'). |
enabledTransports | string[] | ['ws'] | Restrict to WebSocket transport. Disables HTTP polling fallbacks. |
channelAuthorization | object | — | HTTP endpoint and headers for private and presence channel authorization. |
userAuthentication | object | — | HTTP endpoint for connection-level user sign-in (pusher.signin()). |
Connection States
| State | Description |
|---|---|
connecting | Handshake initialization in progress. |
connected | Protocol handshake complete; connection assigned active socket_id. |
unavailable | Network disconnect or timeout; automatic retry in progress. |
failed | Connection rejected (e.g. invalid app key or quota exceeded). |
disconnected | Connection explicitly closed via pusher.disconnect(). |