Skip to main content
Markdown

Examples

Replace YOUR_APP_ID, YOUR_KEY and YOUR_SECRET with those of your site, from Sites → Realtime API keys in your account.

In the browser: pusher-js​

const pusher = new Pusher('YOUR_KEY', {
cluster: 'mt1',
wsHost: 'ws.wordplus.cloud',
wsPort: 443,
wssPort: 443,
forceTLS: true,
enabledTransports: ['ws', 'wss'],
});

const channel = pusher.subscribe('my-channel');
channel.bind('my-event', (data) => console.log(data));

Laravel​

.env:

BROADCAST_CONNECTION=pusher
PUSHER_APP_ID=YOUR_APP_ID
PUSHER_APP_KEY=YOUR_KEY
PUSHER_APP_SECRET=YOUR_SECRET
PUSHER_HOST=rest.wordplus.cloud
PUSHER_PORT=443
PUSHER_SCHEME=https

VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
VITE_PUSHER_HOST=ws.wordplus.cloud

Laravel Echo:

window.Echo = new Echo({
broadcaster: 'pusher',
key: import.meta.env.VITE_PUSHER_APP_KEY,
cluster: 'mt1',
wsHost: import.meta.env.VITE_PUSHER_HOST,
wsPort: 443,
wssPort: 443,
forceTLS: true,
enabledTransports: ['ws', 'wss'],
});

PHP: pusher/pusher-php-server​

$pusher = new Pusher\Pusher('YOUR_KEY', 'YOUR_SECRET', 'YOUR_APP_ID', [
'host' => 'rest.wordplus.cloud',
'port' => 443,
'scheme' => 'https',
'useTLS' => true,
]);

$pusher->trigger('my-channel', 'my-event', ['message' => 'Hello']);

Node.js: pusher​

const Pusher = require('pusher');

const pusher = new Pusher({
appId: 'YOUR_APP_ID',
key: 'YOUR_KEY',
secret: 'YOUR_SECRET',
host: 'rest.wordplus.cloud',
useTLS: true,
});

await pusher.trigger('my-channel', 'my-event', { message: 'Hello' });