Skip to content
Docs/Quickstart
Docs/Getting Started

Quickstart

Minimal connection and event broadcast reference for Socketo.

1. Client Connection

Install the standard Pusher JavaScript client:

bash
npm install pusher-js

Initialize pusher-js configured for Socketo and subscribe to a channel:

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'],
})

const channel = pusher.subscribe('notifications')

channel.bind('alert', (payload: { message: string }) => {
  console.log('Received:', payload.message)
})

2. Backend Event Broadcast

Install the official Pusher server SDK:

bash
npm install pusher

Publish an event from your server:

ts
import Pusher from 'pusher'

const pusher = new Pusher({
  appId: 'YOUR_APP_KEY',
  key: 'YOUR_APP_KEY',
  secret: 'YOUR_APP_SECRET',
  host: 'api.socketo.dev',
  useTLS: true,
})

await pusher.trigger('notifications', 'alert', {
  message: 'Hello from Socketo',
})

3. Local CLI Testing

Broadcast events directly from your terminal during local development:

bash
npx @socketo/cli trigger notifications alert '{"message":"CLI test payload"}'