Quickstart
Connect your first WebSocket client and broadcast events in 60 seconds.
Quickstart
Get up and running with Socketo in less than a minute. In this guide, you will connect a client to Socketo, subscribe to a channel, and trigger your first real-time event from the backend.
1. Get Application Credentials
When using Socketo Cloud, create an app from your dashboard to get your credentials:
- App ID & App Key:
your_app_key - App Secret:
your_app_secret - WebSocket Host (Client):
wss.socketo.dev - REST API Host (Backend):
api.socketo.dev
Note on App Key & App ID: In Socketo Cloud, your App Key and App ID use the same unified identifier (
app.id). When configuring official Pusher server SDKs or framework environment variables, assign this value to bothAPP_IDandAPP_KEY.Local Development: When using
@socketo/cli, you can uselocalfor App ID, Key, and Secret with hostlocalhost:8787.
2. Connect the Client
Install the Pusher client SDK:
npm install pusher-jsInitialize the client and subscribe to a channel:
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('new-message', (data: { text: string; sender: string }) => {
console.log('Received message:', data.text, 'from', data.sender)
})
pusher.connection.bind('connected', () => {
console.log('Connected to Socketo! Socket ID:', pusher.connection.socket_id)
})3. Trigger an Event from Backend
Install the Pusher server SDK in your Node.js project:
npm install pusherTrigger an event to the notifications channel:
import Pusher from 'pusher'
const pusher = new Pusher({
appId: 'YOUR_APP_ID',
key: 'YOUR_APP_KEY',
secret: 'YOUR_APP_SECRET',
host: 'api.socketo.dev',
useTLS: true,
})
await pusher.trigger('notifications', 'new-message', {
text: 'Hello from Socketo!',
sender: 'Backend Worker',
})
console.log('Event triggered successfully!')4. Or Trigger via Socketo CLI
You can also trigger events directly from your terminal:
npx @socketo/cli trigger notifications new-message '{"text":"Hello from CLI!","sender":"Dev"}'Next Steps
- Client Configuration — Explore configuration for
pusher-jsand Laravel Echo. - Backend Configuration — Setup Node.js and Laravel backends.
- Channels Guide — Learn about public, private, and presence channels.