Skip to content
Docs/Client Configuration
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-js

Cloud 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-js

Echo 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

OptionTypeDefaultDescription
wsHoststring—WebSocket domain address (wss.socketo.dev or localhost).
wssPortnumber443Secure TLS port (443).
wsPortnumber80Unencrypted development port (CLI default: 8787).
forceTLSbooleantrueEnforce WSS/TLS encryption. Set to false for local CLI development.
clusterstring'socketo'Routing cluster identifier ('socketo' or 'local').
enabledTransportsstring[]['ws']Restrict to WebSocket transport. Disables HTTP polling fallbacks.
channelAuthorizationobject—HTTP endpoint and headers for private and presence channel authorization.
userAuthenticationobject—HTTP endpoint for connection-level user sign-in (pusher.signin()).

Connection States

StateDescription
connectingHandshake initialization in progress.
connectedProtocol handshake complete; connection assigned active socket_id.
unavailableNetwork disconnect or timeout; automatic retry in progress.
failedConnection rejected (e.g. invalid app key or quota exceeded).
disconnectedConnection explicitly closed via pusher.disconnect().