Docs/Backend Configuration
Docs/Getting Started

Backend Configuration

Configure Node.js and Laravel servers to broadcast events with Socketo.

Backend Configuration

Socketo provides a Pusher-compatible REST API at api.socketo.dev. You can use official Pusher server SDKs to trigger events, send direct user events, terminate connections, and query active channels.

Note on App Key & App ID: In Socketo Cloud, your App Key and App ID use the same unified identifier (app.id). Set both SOCKETO_APP_ID and SOCKETO_APP_KEY to this value in your .env configuration.


Node.js / TypeScript (pusher)

Install the Pusher server SDK:

bash
npm install pusher

Configuration & Triggering

ts
import Pusher from 'pusher'

const pusher = new Pusher({
  appId: process.env.SOCKETO_APP_ID!,
  key: process.env.SOCKETO_APP_KEY!,
  secret: process.env.SOCKETO_APP_SECRET!,
  host: process.env.SOCKETO_HOST ?? 'api.socketo.dev',
  useTLS: true,
})

// Trigger an event to one or more channels
await pusher.trigger(['orders', 'notifications'], 'order-created', {
  orderId: 'ord_12345',
  amount: 49.99,
})

// Send an event directly to a signed-in user (received via pusher.user.bind)
await pusher.sendToUser('user_42', 'order-shipped', {
  orderId: 'ord_12345',
  trackingNumber: 'TRK_98765',
})

Laravel Broadcasting

Socketo acts as a drop-in replacement for Pusher in Laravel applications.

1. Install Pusher Channels Driver

bash
composer require pusher/pusher-php-server

2. Configure 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' => env('SOCKETO_PORT', 443),
            'scheme' => env('SOCKETO_SCHEME', 'https'),
            'useTLS' => env('SOCKETO_SCHEME', 'https') === 'https',
            'cluster' => 'socketo',
        ],
    ],
],

3. Configure .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"

Local Development with CLI: Set SOCKETO_HOST=127.0.0.1, SOCKETO_PORT=8787, SOCKETO_SCHEME=http, and use local for all keys.


Options Reference

ParameterTypeDefaultDescription
appIdstringRequiredYour application ID.
keystringRequiredPublic application key.
secretstringRequiredPrivate application HMAC secret. Never expose in frontend code.
hoststring'api.socketo.dev'REST API host address.
portnumber443Port (443 for TLS, 8787 for local CLI).
useTLS / sslbooleantrueEnforce HTTPS encryption.