Skip to content
Docs/Backend Configuration
Docs/Getting Started

Backend Configuration

Node.js and Laravel broadcasting backend configuration reference.

Node.js / TypeScript (pusher)

Install the official Pusher server SDK:

bash
npm install pusher

SDK Initialization

ts
import Pusher from 'pusher'

const pusher = new Pusher({
  appId: process.env.SOCKETO_APP_KEY!,
  key: process.env.SOCKETO_APP_KEY!,
  secret: process.env.SOCKETO_APP_SECRET!,
  host: process.env.SOCKETO_HOST ?? 'api.socketo.dev',
  port: Number(process.env.SOCKETO_PORT ?? 443),
  useTLS: (process.env.SOCKETO_SCHEME ?? 'https') === 'https',
})

Broadcasting Operations

ts
// 1. Single channel trigger
await pusher.trigger('orders', 'order-created', { id: 'ord_123' })

// 2. Multi-channel broadcast (up to 100 channels)
await pusher.trigger(['orders', 'analytics'], 'order-created', { id: 'ord_123' })

// 3. Socket exclusion (prevent echo to originator)
await pusher.trigger('orders', 'order-created', { id: 'ord_123' }, {
  socket_id: originatingSocketId,
})

// 4. Direct user broadcast (requires pusher.signin() on client)
await pusher.sendToUser('user_42', 'payment-received', { amount: 99.00 })

Laravel Broadcasting

Socketo is a drop-in target for Laravel's native Pusher broadcasting driver.

1. Driver Installation

bash
composer require pusher/pusher-php-server

2. Configuration (config/broadcasting.php)

php
'connections' => [
    'pusher' => [
        'driver' => 'pusher',
        'key' => env('SOCKETO_APP_KEY'),
        'secret' => env('SOCKETO_APP_SECRET'),
        'app_id' => env('SOCKETO_APP_ID'),
        'options' => [
            'host' => env('SOCKETO_HOST', 'api.socketo.dev'),
            'port' => (int) env('SOCKETO_PORT', 443),
            'scheme' => env('SOCKETO_SCHEME', 'https'),
            'useTLS' => env('SOCKETO_SCHEME', 'https') === 'https',
            'cluster' => 'socketo',
        ],
    ],
],

3. Environment Variables (.env)

env
BROADCAST_CONNECTION=pusher

SOCKETO_APP_ID="your-app-key"
SOCKETO_APP_KEY="your-app-key"
SOCKETO_APP_SECRET="your-app-secret"
SOCKETO_HOST="api.socketo.dev"
SOCKETO_PORT=443
SOCKETO_SCHEME="https"

Backend Options Reference

ParameterTypeRequiredDescription
appIdstringYesApplication ID. Matches key in Socketo Cloud.
keystringYesPublic application key.
secretstringYesPrivate HMAC secret for signing requests.
hoststringYesREST API hostname (api.socketo.dev or localhost).
portnumberNoAPI port (443 for TLS, 8787 for local CLI).
useTLSbooleanNoEnables HTTPS request transmission.