realtime_check_permission( )


Checks permissions for a subscriber on a channel or channel resource.

This is a hook, not a method you call directly. Define this function as a named export in a file called realtime-permissions.js in your site's backend. It runs automatically when a site visitor subscribes to a channel.

Important:

  • If this function isn't defined, all subscribers receive the default permissions: {"read": true}.
  • In Wix Studio, you don't need to define this function, but you must create a backend file named realtime-permissions.js. Without this file, subscriptions fail.

Implement permissions logic in one of the following ways:

  • Include all permissions logic directly in the body of this function.
  • Use the permissionsRouter to add permissions logic per channel, then call permissionsRouter.check() in the body of this function and return its result.

Note: When previewing your site, read permissions are always granted.

Method Declaration
Copy
Method Parameters
channelChannelRequired

Channel, and optionally resource, to check permissions for.


subscriberSubscriberRequired

Subscriber to check permissions for.

Returns
Return Type:Promise<ChannelPermissions>
Errors

This method doesn't return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?