The Permissions Router API is a utility for organizing channel permission logic. The router lets you set up a default permissions handler as well as handlers specific to channels or resources.
Note: Alternatively, you can include permissions logic in the realtime_check_permission() hook.
Learn more about the Site API and the Realtime APIs.
With the Permissions Router API, you can:
To set up permissions:
realtime_check_permission hook. This hook runs automatically whenever a subscription is attempted.permissionsRouter.check() to evaluate the subscriber's permissions based on the handlers you've registered.Permissions can be set at the channel level or the resource level. They determine whether subscribers can receive messages published to that channel or resource.
Permissions follow a cascading pattern:
{ "read": true }.It's important to note the following points before starting to code:
realtime_check_permission hook isn't defined, all subscribers receive the default permissions of {"read": true}.read permissions are always true.