About the Site API

The Site API lets you control subscriber permissions for the Realtime APIs. It determines which subscribers can receive messages on specific channels and resources.

With the Site API, you can:

Important: You can only use the Site API when developing websites. When building apps, subscribers receive the default { read: true } permissions.

To provide custom permission checks for channels your app manages, implement the Realtime Permissions service plugin.

Learn more about cross-app subscriptions.

Before you begin

It's important to note the following points before starting to code:

  • In Wix Studio, you must create a realtime-permissions.js file in a site's backend, even if realtime_check_permission isn't defined. Without the file, subscriptions fail.
  • When the realtime_check_permission hook isn't defined, all subscribers receive the default permissions of {"read": true}.
  • When previewing a site, read permissions are always true.

Use cases

Restrict a channel so only the Wix user can receive messages. Use the permissions router to add a handler that checks subscriber.type:

Copy

See also

Did this help?