Back to Documentation

JavaScript SDK Examples

Real-world examples showing how to use the OddSockets JavaScript SDK in production applications

Try Interactive Demo
Basic Usage
Available
Simple example showing how to connect, subscribe to a channel, and publish messages using the core SDK functionality.
const OddSockets = require('@oddsockets/js');

const client = new OddSockets({
  apiKey: 'ak_live_1234567890abcdef'
});

const channel = client.channel('my-channel');

// Subscribe to messages
channel.subscribe((message) => {
  console.log('Received:', message);
});

// Publish a message
channel.publish('Hello, World!');