SDK
SDK Javascript v6.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

publish #

Sends a real-time message to Kuzzle. The message will be dispatched to all clients with subscriptions matching the index, the collection and the message content.

The index and collection are indicative and serve only to distinguish the rooms. They are not required to exist in the database

Note: real-time messages are not persisted in the database.


Copied to clipboard!
publish(index, collection, message, [options]);

Arguments Type Description
index
string
Index name
collection
string
Collection name
message
object
Message to send
options
object
Query options

options #

Additional query options

Option Type
(default)
Description
queuable
boolean

(true)
Make this request queuable or not

Resolves #

A boolean indicating if the message was successfully published.

Usage #

Copied to clipboard!
const message = { realtime: 'rule the web' };
try {
  await kuzzle.realtime.publish(
    'i-dont-exist',
    'in-database',
    message
  );
  console.log('Success');
} catch (error) {
  console.error(error.message);
}