Quick Start

Get Soketify integrated into your application in under 5 minutes. This guide walks you through creating an app, connecting a client, and sending your first real-time event.

1. Sign Up and Create an App

First, create a Soketify account. Once you are logged in, navigate to the Dashboard and click Create App.

After creating your app, you will see your credentials on the app settings page:

  • App ID your unique application identifier
  • App Key the public key used by your client-side code
  • App Secret the private key used by your server-side code (never expose this publicly)

Keep Your Secret Safe

Your App Secret must never be included in client-side JavaScript, committed to version control, or shared publicly. It is used only on your server for authenticating API requests and private channel subscriptions.

2. Install the Client Library

Soketify uses the official pusher-js client library. Install it in your frontend project:

Terminal
bash
npm install pusher-js

You can also use yarn or pnpm:

Terminal
bash
yarn add pusher-js
# or
pnpm add pusher-js

3. Connect from the Client

Initialize the Pusher client with your Soketify credentials. The only difference from a standard Pusher setup is the wsHost and cluster configuration:

client.js
javascript
1import Pusher from "pusher-js";
2
3const pusher = new Pusher("YOUR_APP_KEY", {
4  wsHost: "ws.soketify.com",
5  wsPort: 443,
6  wssPort: 443,
7  forceTLS: true,
8  disableStats: true,
9  enabledTransports: ["ws", "wss"],
10  cluster: "default",
11});
12
13// Subscribe to a channel
14const channel = pusher.subscribe("my-channel");
15
16// Listen for events
17channel.bind("my-event", (data) => {
18  console.log("Received event:", data);
19});
20
21// Handle connection state changes
22pusher.connection.bind("state_change", (states) => {
23  console.log("Connection state:", states.current);
24});

Info

The cluster parameter is required by the Pusher client but is not used by Soketify for routing. You can set it to any value (e.g., cluster parameter is required by the Pusher client but is not used by Soketify for routing. You can set it to any value (e.g., "default").

4. Send Events from the Server

Install the Pusher server library for your language. Here is the Node.js example:

Terminal
bash
npm install pusher

Then configure it to point to Soketify:

server.js
javascript
1const Pusher = require("pusher");
2
3const pusher = new Pusher({
4  appId: "YOUR_APP_ID",
5  key: "YOUR_APP_KEY",
6  secret: "YOUR_APP_SECRET",
7  host: "api.soketify.com",
8  port: "443",
9  useTLS: true,
10  cluster: "default",
11});
12
13// Trigger an event
14await pusher.trigger("my-channel", "my-event", {
15  message: "Hello from Soketify!",
16  timestamp: Date.now(),
17});
18
19console.log("Event sent successfully!");

That is it. The event will be delivered to all clients subscribed to my-channel in real time.

5. Subscribe to More Channels

You can subscribe to multiple channels and bind to different events:

channels.js
javascript
1// Public channel - anyone can subscribe
2const publicChannel = pusher.subscribe("news");
3publicChannel.bind("breaking", (data) => {
4  console.log("Breaking news:", data.headline);
5});
6
7// Private channel - requires server-side authentication
8const privateChannel = pusher.subscribe("private-user-123");
9privateChannel.bind("notification", (data) => {
10  console.log("Private notification:", data);
11});
12
13// Presence channel - tracks online members
14const presenceChannel = pusher.subscribe("presence-chat-room");
15presenceChannel.bind("pusher:subscription_succeeded", (members) => {
16  console.log("Members online:", members.count);
17});
18presenceChannel.bind("pusher:member_added", (member) => {
19  console.log("User joined:", member.info.name);
20});

Private and Presence Channels

Private and presence channels require a server-side authentication endpoint. See the Authentication guide for setup instructions.

6. Trigger Events from the Server

You can trigger events to specific channels, multiple channels, or exclude a socket from receiving its own event:

server-events.js
javascript
1// Trigger to a single channel
2await pusher.trigger("my-channel", "new-message", {
3  user: "Alice",
4  text: "Hello, world!",
5});
6
7// Trigger to multiple channels at once (up to 100)
8await pusher.trigger(
9  ["channel-1", "channel-2", "channel-3"],
10  "update",
11  { version: 2 }
12);
13
14// Exclude a specific socket (useful for the sender)
15await pusher.trigger("chat-room", "new-message", {
16  user: "Bob",
17  text: "Hi everyone!",
18}, {
19  socket_id: "12345.67890",  // sender's socket ID
20});

Next Steps