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 bothSOCKETO_APP_IDandSOCKETO_APP_KEYto this value in your.envconfiguration.
Node.js / TypeScript (pusher)
Install the Pusher server SDK:
bash
npm install pusherConfiguration & 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-server2. 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 uselocalfor all keys.
Options Reference
| Parameter | Type | Default | Description |
|---|---|---|---|
appId | string | Required | Your application ID. |
key | string | Required | Public application key. |
secret | string | Required | Private application HMAC secret. Never expose in frontend code. |
host | string | 'api.socketo.dev' | REST API host address. |
port | number | 443 | Port (443 for TLS, 8787 for local CLI). |
useTLS / ssl | boolean | true | Enforce HTTPS encryption. |