@wix/realtime 1.0.34 → 1.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -38,15 +38,7 @@
38
38
  "summary": [
39
39
  {
40
40
  "kind": "text",
41
- "text": "Publishes a message to a channel or channel resource.\n\nAll subscribers currently listening to the specified channel receive the\nmessage. Subscribers to a channel don't receive messages published to a\nresource on that channel, and vice versa.\n\nThis method is backend-only and requires elevated permissions.\n\n<!-- TODO: Check whether this API is relevant for headless projects. -->\n\n> **Note:** This function requires elevated permissions and runs only on the backend.\n> You can also call this method from the frontend using "
42
- },
43
- {
44
- "kind": "code",
45
- "text": "`elevate()`"
46
- },
47
- {
48
- "kind": "text",
49
- "text": ".\n> Elevated permissions are only available for apps and service accounts."
41
+ "text": "Publishes a message to a channel or resource.\n\nThe method publishes a message to all subscriptions on the specified channel or resource. Channels and resources are isolated, so subscribers to a channel don't receive messages published to a resource. Similarly, subscribers to a resource don't receive messages published to the parent channel.\n\n> **Authentication**\n>\n> This method may require higher-level permissions than the caller has, based on their [identity](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities) and [roles and permissions](https://support.wix.com/en/article/roles-permissions-overview). In these cases, you can ensure the method is called with the required level of authorization by using [elevated permissions](https://dev.wix.com/docs/api-reference/articles/authentication/about-elevated-permissions).\n\n<!-- TODO: Check whether this API is relevant for headless projects. -->"
50
42
  }
51
43
  ],
52
44
  "blockTags": [
@@ -55,11 +47,11 @@
55
47
  "content": [
56
48
  {
57
49
  "kind": "text",
58
- "text": "Manual client (self-hosted / explicit auth)\n"
50
+ "text": "Publish a message to the specified channel\n"
59
51
  },
60
52
  {
61
53
  "kind": "code",
62
- "text": "```ts\nimport { publisher } from '@wix/realtime';\nimport { createClient, AppStrategy } from '@wix/sdk';\n\nconst client = createClient({\n modules: { publisher },\n auth: AppStrategy({ appId, appSecret, instanceId }),\n});\nawait client.publisher.publish({ name: 'my-channel' }, { message: 'hello' });\n```"
54
+ "text": "```ts\nimport { publisher } from '@wix/realtime';\nimport { elevate } from '@wix/sdk/context';\n\nawait elevate(publisher.publish)({ name: 'my-channel' }, { message: 'hello' });\n```"
63
55
  }
64
56
  ]
65
57
  },
@@ -68,11 +60,11 @@
68
60
  "content": [
69
61
  {
70
62
  "kind": "text",
71
- "text": "Contextual client (Wix-hosted)\n"
63
+ "text": "Publish a message to the specified channel: Self-hosted\n"
72
64
  },
73
65
  {
74
66
  "kind": "code",
75
- "text": "```ts\nimport { publisher } from '@wix/realtime';\nimport { elevate } from '@wix/sdk/context';\n\nawait elevate(publisher.publish)({ name: 'my-channel' }, { message: 'hello' });\n```"
67
+ "text": "```ts\nimport { publisher } from '@wix/realtime';\nimport { createClient } from '@wix/sdk';\n\n// Import the auth strategy for the relevant access type\n// Import the relevant host module if needed\n\nconst client = createClient({\n modules: { publisher },\n // Include the auth strategy and host as relevant\n});\n\nawait client.publisher.publish({ name: 'my-channel' }, { message: 'hello' });\n```"
76
68
  }
77
69
  ]
78
70
  }
@@ -89,7 +81,7 @@
89
81
  "summary": [
90
82
  {
91
83
  "kind": "text",
92
- "text": "Channel, and optionally resource, to publish to."
84
+ "text": "Channel or resource to publish to."
93
85
  }
94
86
  ]
95
87
  },
@@ -161,15 +153,7 @@
161
153
  "summary": [
162
154
  {
163
155
  "kind": "text",
164
- "text": "Publishes a message to a channel or channel resource.\n\nAll subscribers currently listening to the specified channel receive the\nmessage. Subscribers to a channel don't receive messages published to a\nresource on that channel, and vice versa.\n\nThis method is backend-only and requires elevated permissions.\n\n<!-- TODO: Check whether this API is relevant for headless projects. -->\n\n> **Note:** This function requires elevated permissions and runs only on the backend.\n> You can also call this method from the frontend using "
165
- },
166
- {
167
- "kind": "code",
168
- "text": "`elevate()`"
169
- },
170
- {
171
- "kind": "text",
172
- "text": ".\n> Elevated permissions are only available for apps and service accounts."
156
+ "text": "Publishes a message to a channel or resource.\n\nThe method publishes a message to all subscriptions on the specified channel or resource. Channels and resources are isolated, so subscribers to a channel don't receive messages published to a resource. Similarly, subscribers to a resource don't receive messages published to the parent channel.\n\n> **Authentication**\n>\n> This method may require higher-level permissions than the caller has, based on their [identity](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities) and [roles and permissions](https://support.wix.com/en/article/roles-permissions-overview). In these cases, you can ensure the method is called with the required level of authorization by using [elevated permissions](https://dev.wix.com/docs/api-reference/articles/authentication/about-elevated-permissions).\n\n<!-- TODO: Check whether this API is relevant for headless projects. -->"
173
157
  }
174
158
  ],
175
159
  "blockTags": [
@@ -178,11 +162,11 @@
178
162
  "content": [
179
163
  {
180
164
  "kind": "text",
181
- "text": "Manual client (self-hosted / explicit auth)\n"
165
+ "text": "Publish a message to the specified channel\n"
182
166
  },
183
167
  {
184
168
  "kind": "code",
185
- "text": "```ts\nimport { publisher } from '@wix/realtime';\nimport { createClient, AppStrategy } from '@wix/sdk';\n\nconst client = createClient({\n modules: { publisher },\n auth: AppStrategy({ appId, appSecret, instanceId }),\n});\nawait client.publisher.publish({ name: 'my-channel' }, { message: 'hello' });\n```"
169
+ "text": "```ts\nimport { publisher } from '@wix/realtime';\nimport { elevate } from '@wix/sdk/context';\n\nawait elevate(publisher.publish)({ name: 'my-channel' }, { message: 'hello' });\n```"
186
170
  }
187
171
  ]
188
172
  },
@@ -191,11 +175,11 @@
191
175
  "content": [
192
176
  {
193
177
  "kind": "text",
194
- "text": "Contextual client (Wix-hosted)\n"
178
+ "text": "Publish a message to the specified channel: Self-hosted\n"
195
179
  },
196
180
  {
197
181
  "kind": "code",
198
- "text": "```ts\nimport { publisher } from '@wix/realtime';\nimport { elevate } from '@wix/sdk/context';\n\nawait elevate(publisher.publish)({ name: 'my-channel' }, { message: 'hello' });\n```"
182
+ "text": "```ts\nimport { publisher } from '@wix/realtime';\nimport { createClient } from '@wix/sdk';\n\n// Import the auth strategy for the relevant access type\n// Import the relevant host module if needed\n\nconst client = createClient({\n modules: { publisher },\n // Include the auth strategy and host as relevant\n});\n\nawait client.publisher.publish({ name: 'my-channel' }, { message: 'hello' });\n```"
199
183
  }
200
184
  ]
201
185
  }
@@ -265,7 +249,7 @@
265
249
  "summary": [
266
250
  {
267
251
  "kind": "text",
268
- "text": "Manages subscriber permissions on channels.\n\nUse the permissions router to define which subscribers can receive messages\non specific channels or channel resources. The router allows you to set permissions at the\nchannel level and the channel resource level. If you don't define\npermissions for a particular resource, it inherits the permissions of its\nparent channel.\n\nTypically, you use the permissions router in the **realtime-permissions.js**\nfile in your site's backend to:\n\n+ Set default permissions for all channels where no explicit permissions\n are defined.\n+ Add permissions logic for specific channels or channel resources.\n+ Check the permissions for a subscriber on a channel.\n\n> **Note:** You don't have to use the permissions router. You can also\n> define all your permissions logic directly in the\n> "
252
+ "text": "Realtime permissions router.\n\nDefines which subscribers can receive messages on specific channels or resources. You can set permissions at the channel level as well as the resource level. When a resource isn't assigned explicit permissions, it inherits the permissions of its parent channel.\n\nUse the permissions router in the **realtime-permissions.js** file in the site's backend to:\n\n- Set default permissions for all channels that don't have explicit permissions.\n- Add permissions logic for specific channels or resources.\n- Check permissions for a subscriber on a channel or resource.\n\n> **Note:** You can also define permissions directly in the "
269
253
  },
270
254
  {
271
255
  "kind": "code",
@@ -273,7 +257,7 @@
273
257
  },
274
258
  {
275
259
  "kind": "text",
276
- "text": " function."
260
+ "text": " hook."
277
261
  }
278
262
  ]
279
263
  },
@@ -295,7 +279,7 @@
295
279
  "summary": [
296
280
  {
297
281
  "kind": "text",
298
- "text": "Sets a permissions handler for a specific channel or channel resource.\n\nAdding a handler to a channel without specifying a resource applies the\nhandler to the channel itself and to any of its resources that don't have\ntheir own handler.\n\nFor example, given the following setup:\n\n+ channel: A, permissions: handler X (set with "
282
+ "text": "Sets a permissions handler for a specific channel or resource.\n\nAdding a handler to a channel without specifying a resource applies the\nhandler to the channel itself and to any of its resources that don't have\ntheir own handler.\n\nFor example, given the following setup:\n\n+ channel: A, permissions: handler X (set with "
299
283
  },
300
284
  {
301
285
  "kind": "code",
@@ -364,7 +348,7 @@
364
348
  "summary": [
365
349
  {
366
350
  "kind": "text",
367
- "text": "Channel or channel resource to set a permissions handler for."
351
+ "text": "Channel or resource to set a permissions handler for."
368
352
  }
369
353
  ]
370
354
  },
@@ -385,7 +369,7 @@
385
369
  "summary": [
386
370
  {
387
371
  "kind": "text",
388
- "text": "Function to run when checking permissions for the specified channel."
372
+ "text": "Handler to run when checking permissions for the specified channel."
389
373
  }
390
374
  ]
391
375
  },
@@ -441,7 +425,7 @@
441
425
  "summary": [
442
426
  {
443
427
  "kind": "text",
444
- "text": "Checks the permissions for a subscriber on a channel or channel resource.\n\nThe resolution chain is:\n\n1. If a handler exists for the specified channel or resource, it runs and\n its result is returned.\n1. If no handler exists for the resource, the parent channel's handler\n runs instead.\n1. If no channel handler exists, the default handler runs.\n1. If no default handler is set, the built-in default permissions are\n returned: "
428
+ "text": "Checks permissions for a subscriber on a channel or resource.\n\nThe resolution chain is:\n\n1. If a handler exists for the specified channel or resource, it runs and\n its result is returned.\n1. If no handler exists for the resource, the parent channel's handler\n runs instead.\n1. If no channel handler exists, the default handler runs.\n1. If no default handler is set, the built-in default permissions are\n returned: "
445
429
  },
446
430
  {
447
431
  "kind": "code",
@@ -506,7 +490,7 @@
506
490
  "content": [
507
491
  {
508
492
  "kind": "text",
509
- "text": "The permissions granted to the subscriber."
493
+ "text": "Permissions granted to the subscriber for the specified channel or resource."
510
494
  }
511
495
  ]
512
496
  },
@@ -541,7 +525,7 @@
541
525
  "summary": [
542
526
  {
543
527
  "kind": "text",
544
- "text": "Channel or channel resource to check permissions for."
528
+ "text": "Channel or resource to check permissions for."
545
529
  }
546
530
  ]
547
531
  },
@@ -689,7 +673,7 @@
689
673
  "summary": [
690
674
  {
691
675
  "kind": "text",
692
- "text": "Function to run when checking default permissions."
676
+ "text": "Handler to run when checking default permissions."
693
677
  }
694
678
  ]
695
679
  },
@@ -745,7 +729,7 @@
745
729
  "summary": [
746
730
  {
747
731
  "kind": "text",
748
- "text": "A function that determines the permissions for a subscriber on a channel\nor channel resource. Return a "
732
+ "text": "Determines the permissions for a subscriber on a channel or resource. Return a "
749
733
  },
750
734
  {
751
735
  "kind": "code",
@@ -753,7 +737,7 @@
753
737
  },
754
738
  {
755
739
  "kind": "text",
756
- "text": " object to grant or deny\naccess."
740
+ "text": " object to grant or deny access."
757
741
  }
758
742
  ],
759
743
  "blockTags": [
@@ -824,7 +808,7 @@
824
808
  "summary": [
825
809
  {
826
810
  "kind": "text",
827
- "text": "Channel or channel resource being checked."
811
+ "text": "Channel or resource being checked."
828
812
  }
829
813
  ]
830
814
  },
@@ -907,7 +891,7 @@
907
891
  "summary": [
908
892
  {
909
893
  "kind": "text",
910
- "text": "Sets a permissions handler for a specific channel or channel resource.\n\nAdding a handler to a channel without specifying a resource applies the\nhandler to the channel itself and to any of its resources that don't have\ntheir own handler.\n\nFor example, given the following setup:\n\n+ channel: A, permissions: handler X (set with "
894
+ "text": "Sets a permissions handler for a specific channel or resource.\n\nAdding a handler to a channel without specifying a resource applies the\nhandler to the channel itself and to any of its resources that don't have\ntheir own handler.\n\nFor example, given the following setup:\n\n+ channel: A, permissions: handler X (set with "
911
895
  },
912
896
  {
913
897
  "kind": "code",
@@ -976,7 +960,7 @@
976
960
  "summary": [
977
961
  {
978
962
  "kind": "text",
979
- "text": "Channel or channel resource to set a permissions handler for."
963
+ "text": "Channel or resource to set a permissions handler for."
980
964
  }
981
965
  ]
982
966
  },
@@ -1044,7 +1028,7 @@
1044
1028
  "summary": [
1045
1029
  {
1046
1030
  "kind": "text",
1047
- "text": "Checks the permissions for a subscriber on a channel or channel resource.\n\nThe resolution chain is:\n\n1. If a handler exists for the specified channel or resource, it runs and\n its result is returned.\n1. If no handler exists for the resource, the parent channel's handler\n runs instead.\n1. If no channel handler exists, the default handler runs.\n1. If no default handler is set, the built-in default permissions are\n returned: "
1031
+ "text": "Checks the permissions for a subscriber on a channel or resource.\n\nThe resolution chain is:\n\n1. If a handler exists for the specified channel or resource, it runs and\n its result is returned.\n1. If no handler exists for the resource, the parent channel's handler\n runs instead.\n1. If no channel handler exists, the default handler runs.\n1. If no default handler is set, the built-in default permissions are\n returned: "
1048
1032
  },
1049
1033
  {
1050
1034
  "kind": "code",
@@ -1109,7 +1093,7 @@
1109
1093
  "content": [
1110
1094
  {
1111
1095
  "kind": "text",
1112
- "text": "The permissions granted to the subscriber."
1096
+ "text": "Permissions granted to the subscriber for the specified channel or resource."
1113
1097
  }
1114
1098
  ]
1115
1099
  },
@@ -1144,7 +1128,7 @@
1144
1128
  "summary": [
1145
1129
  {
1146
1130
  "kind": "text",
1147
- "text": "Channel or channel resource to check permissions for."
1131
+ "text": "Channel or resource to check permissions for."
1148
1132
  }
1149
1133
  ]
1150
1134
  },
@@ -1334,7 +1318,7 @@
1334
1318
  "summary": [
1335
1319
  {
1336
1320
  "kind": "text",
1337
- "text": "A realtime channel that subscribers can listen to and publishers can send messages to.\nA channel can optionally contain resources, which act as isolated sub-channels.\nSubscribing to a channel doesn't include messages published to its resources, and vice versa."
1321
+ "text": "Realtime broadcast channel. Publishers send messages to channels and subscribers listen to them."
1338
1322
  }
1339
1323
  ]
1340
1324
  },
@@ -1349,7 +1333,7 @@
1349
1333
  "summary": [
1350
1334
  {
1351
1335
  "kind": "text",
1352
- "text": "Channel name. Supports alphanumeric characters, hyphens, and underscores.\nThe combined length of "
1336
+ "text": "Channel name.\n\n> **Notes:**\n> - Supports only alphanumeric characters, hyphens, and underscores.\n> - The combined length of "
1353
1337
  },
1354
1338
  {
1355
1339
  "kind": "code",
@@ -1386,15 +1370,7 @@
1386
1370
  "summary": [
1387
1371
  {
1388
1372
  "kind": "text",
1389
- "text": "Resource ID within the channel. Use resources to isolate messages within a channel.\nFor example, a "
1390
- },
1391
- {
1392
- "kind": "code",
1393
- "text": "`chat`"
1394
- },
1395
- {
1396
- "kind": "text",
1397
- "text": " channel might use a separate resource for each chat room."
1373
+ "text": "Resource ID.\n\nResources are isolated sub-channels in a channel. A subscriber listening to a resource doesn't receive messages published to the parent channel, and vice versa."
1398
1374
  }
1399
1375
  ]
1400
1376
  },
@@ -1424,7 +1400,7 @@
1424
1400
  "summary": [
1425
1401
  {
1426
1402
  "kind": "text",
1427
- "text": "Permission settings for a subscriber on a channel or channel resource."
1403
+ "text": "Permissions for a subscriber on a channel or resource."
1428
1404
  }
1429
1405
  ]
1430
1406
  },
@@ -1446,6 +1422,10 @@
1446
1422
  {
1447
1423
  "kind": "code",
1448
1424
  "text": "`true`"
1425
+ },
1426
+ {
1427
+ "kind": "text",
1428
+ "text": "."
1449
1429
  }
1450
1430
  ]
1451
1431
  },
@@ -1553,15 +1533,7 @@
1553
1533
  "summary": [
1554
1534
  {
1555
1535
  "kind": "text",
1556
- "text": "A channel subscriber whose permissions are being checked.\nPassed to the "
1557
- },
1558
- {
1559
- "kind": "code",
1560
- "text": "`realtime_check_permission()`"
1561
- },
1562
- {
1563
- "kind": "text",
1564
- "text": " hook to identify the subscriber."
1536
+ "text": "Subscriber to a channel or resource.\n\nWix checks [subscriber permissions](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/realtime-check-permission) before they can listen to messages."
1565
1537
  }
1566
1538
  ]
1567
1539
  },
@@ -1606,7 +1578,7 @@
1606
1578
  "summary": [
1607
1579
  {
1608
1580
  "kind": "text",
1609
- "text": "Subscriber type, based on their authentication status."
1581
+ "text": "Subscriber identity type.\n\nLearn more about [Wix identities](https://dev.wix.com/docs/build-apps/develop-your-app/access/about-identities)."
1610
1582
  }
1611
1583
  ],
1612
1584
  "blockTags": [
@@ -1654,7 +1626,7 @@
1654
1626
  "summary": [
1655
1627
  {
1656
1628
  "kind": "text",
1657
- "text": "The realtime permissions router.\n\nUse the permissions router to define which subscribers can receive messages\non specific channels or channel resources. You can set permissions at the\nchannel level and the channel resource level. If you don't define\npermissions for a particular resource, it inherits the permissions of its\nparent channel.\n\nTypically, you use the permissions router in the **realtime-permissions.js**\nfile in your site's backend to:\n\n+ Set default permissions for all channels where no explicit permissions\n are defined.\n+ Add permissions logic for specific channels or channel resources.\n+ Check the permissions for a subscriber on a channel.\n\n> **Note:** You don't have to use the permissions router. You can also\n> define all your permissions logic directly in the\n> "
1629
+ "text": "Realtime permissions router.\n\nDefines which subscribers can receive messages on specific channels or resources. You can set permissions at the channel level as well as the resource level. When a resource isn't assigned explicit permissions, it inherits the permissions of its parent channel.\n\nUse the permissions router in the **realtime-permissions.js** file in the site's backend to:\n\n- Set default permissions for all channels that don't have explicit permissions.\n- Add permissions logic for specific channels or resources.\n- Check permissions for a subscriber on a channel or resource.\n\n> **Note:** You can also define permissions directly in the ["
1658
1630
  },
1659
1631
  {
1660
1632
  "kind": "code",
@@ -1662,7 +1634,7 @@
1662
1634
  },
1663
1635
  {
1664
1636
  "kind": "text",
1665
- "text": " function."
1637
+ "text": "](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/realtime-check-permission) hook."
1666
1638
  }
1667
1639
  ],
1668
1640
  "blockTags": [
@@ -1701,7 +1673,39 @@
1701
1673
  "summary": [
1702
1674
  {
1703
1675
  "kind": "text",
1704
- "text": "Publishes a message to a channel or channel resource."
1676
+ "text": "Publishes a message to a channel or resource.\n\nSubscribers to a channel don't receive messages published to a resource on\nthat channel, and vice versa.\n\nTo publish a message to specific users only, specify the users by ID in\nthe "
1677
+ },
1678
+ {
1679
+ "kind": "code",
1680
+ "text": "`options`"
1681
+ },
1682
+ {
1683
+ "kind": "text",
1684
+ "text": " parameter. To include the publisher's identity in the message,\nset "
1685
+ },
1686
+ {
1687
+ "kind": "code",
1688
+ "text": "`includePublisher`"
1689
+ },
1690
+ {
1691
+ "kind": "text",
1692
+ "text": " to "
1693
+ },
1694
+ {
1695
+ "kind": "code",
1696
+ "text": "`true`"
1697
+ },
1698
+ {
1699
+ "kind": "text",
1700
+ "text": " in the "
1701
+ },
1702
+ {
1703
+ "kind": "code",
1704
+ "text": "`options`"
1705
+ },
1706
+ {
1707
+ "kind": "text",
1708
+ "text": " parameter."
1705
1709
  }
1706
1710
  ],
1707
1711
  "blockTags": [
@@ -1726,64 +1730,7 @@
1726
1730
  },
1727
1731
  {
1728
1732
  "kind": "text",
1729
- "text": " module instead.\n\nSubscribers to a channel don't receive messages published to a resource on\nthat channel, and vice versa.\n\nTo publish a message to specific users only, specify the users by ID in\nthe "
1730
- },
1731
- {
1732
- "kind": "code",
1733
- "text": "`options`"
1734
- },
1735
- {
1736
- "kind": "text",
1737
- "text": " parameter. To include the publisher's identity in the message,\nset "
1738
- },
1739
- {
1740
- "kind": "code",
1741
- "text": "`includePublisher`"
1742
- },
1743
- {
1744
- "kind": "text",
1745
- "text": " to "
1746
- },
1747
- {
1748
- "kind": "code",
1749
- "text": "`true`"
1750
- },
1751
- {
1752
- "kind": "text",
1753
- "text": " in the "
1754
- },
1755
- {
1756
- "kind": "code",
1757
- "text": "`options`"
1758
- },
1759
- {
1760
- "kind": "text",
1761
- "text": " parameter."
1762
- }
1763
- ]
1764
- },
1765
- {
1766
- "tag": "@deprecated",
1767
- "content": [
1768
- {
1769
- "kind": "text",
1770
- "text": "Use "
1771
- },
1772
- {
1773
- "kind": "code",
1774
- "text": "`publisher.publish`"
1775
- },
1776
- {
1777
- "kind": "text",
1778
- "text": " from "
1779
- },
1780
- {
1781
- "kind": "code",
1782
- "text": "`@wix/realtime`"
1783
- },
1784
- {
1785
- "kind": "text",
1786
- "text": " instead."
1733
+ "text": " module instead."
1787
1734
  }
1788
1735
  ]
1789
1736
  },
@@ -1828,7 +1775,7 @@
1828
1775
  "content": [
1829
1776
  {
1830
1777
  "kind": "text",
1831
- "text": "Fulfilled when the message is published. Doesn't indicate that the message was received by subscribers."
1778
+ "text": "Resolves when the message is published. Doesn't indicate that the message was received by subscribers."
1832
1779
  }
1833
1780
  ]
1834
1781
  }
@@ -1934,23 +1881,39 @@
1934
1881
  "summary": [
1935
1882
  {
1936
1883
  "kind": "text",
1937
- "text": "Checks permissions for a subscriber on a channel or channel resource.\n\nThis is a hook, not a method you call directly. Define this function as a\nnamed export in a file called **realtime-permissions.js** in your site's\nbackend. It runs automatically when a site visitor subscribes to a channel.\n\n> **Important:**\n> - If this function isn't defined, all subscribers receive the default\n> permissions: "
1884
+ "text": "Checks permissions for a subscriber on a channel or resource.\n\nThis handler runs automatically whenever a new subscription is attempted. Define it as a named export in the **realtime-permissions.js** file in the site's backend.\n\n> **Notes:**\n>\n> - When this handler isn't defined, all subscribers are assigned the default permissions of "
1885
+ },
1886
+ {
1887
+ "kind": "code",
1888
+ "text": "`\"read\": true`"
1889
+ },
1890
+ {
1891
+ "kind": "text",
1892
+ "text": ".\n> - When previewing the site, "
1893
+ },
1894
+ {
1895
+ "kind": "code",
1896
+ "text": "`read`"
1897
+ },
1898
+ {
1899
+ "kind": "text",
1900
+ "text": " permissions are always set to "
1938
1901
  },
1939
1902
  {
1940
1903
  "kind": "code",
1941
- "text": "`{\"read\": true}`"
1904
+ "text": "`true`"
1942
1905
  },
1943
1906
  {
1944
1907
  "kind": "text",
1945
- "text": ".\n> - In Wix Studio, you don't need to define this function, but you must\n> create a backend file named **realtime-permissions.js**. Without this\n> file, subscriptions fail.\n\nImplement permissions logic in one of the following ways:\n\n+ Include all permissions logic directly in the body of this function.\n+ Use the "
1908
+ "text": ".\n> - In Wix Studio, you don't need to define this handler. However, you must create the **realtime-permissions.js** file. Without it, all subscriptions fail.\n\nYou can set up permissions logic by:\n\n- Including all permissions logic directly in the handler body.\n- Defining permissions logic per channel or resource with "
1946
1909
  },
1947
1910
  {
1948
1911
  "kind": "code",
1949
- "text": "`permissionsRouter`"
1912
+ "text": "`permissionsRouter.add()`"
1950
1913
  },
1951
1914
  {
1952
1915
  "kind": "text",
1953
- "text": " to add permissions logic per channel, then\n call "
1916
+ "text": ", then calling "
1954
1917
  },
1955
1918
  {
1956
1919
  "kind": "code",
@@ -1958,7 +1921,7 @@
1958
1921
  },
1959
1922
  {
1960
1923
  "kind": "text",
1961
- "text": " in the body of this function and return\n its result.\n\n> **Note:** When previewing your site, read permissions are always granted."
1924
+ "text": " to evaluate each subscription request."
1962
1925
  }
1963
1926
  ],
1964
1927
  "blockTags": [
@@ -2003,7 +1966,7 @@
2003
1966
  "content": [
2004
1967
  {
2005
1968
  "kind": "text",
2006
- "text": "The permissions granted to the subscriber on the channel or channel resource."
1969
+ "text": "Permissions granted to the subscriber for the specified channel or resource."
2007
1970
  }
2008
1971
  ]
2009
1972
  },
@@ -2038,7 +2001,7 @@
2038
2001
  "summary": [
2039
2002
  {
2040
2003
  "kind": "text",
2041
- "text": "Channel, and optionally resource, to check permissions for."
2004
+ "text": "Channel and resource to check permissions for."
2042
2005
  }
2043
2006
  ]
2044
2007
  },
@@ -2147,7 +2110,7 @@
2147
2110
  "summary": [
2148
2111
  {
2149
2112
  "kind": "text",
2150
- "text": "Subscribes to a channel or channel resource.\n\nThe method returns a subscription ID immediately. The connection is\nestablished asynchronously in the background. Use the "
2113
+ "text": "Subscribes to a channel or resource.\n\nThe method attempts to establish a subscription to the specified channel or resource. While the subscription is attempted asynchronously, the method returns the subscription ID immediately.\n\nUse the "
2151
2114
  },
2152
2115
  {
2153
2116
  "kind": "code",
@@ -2155,15 +2118,15 @@
2155
2118
  },
2156
2119
  {
2157
2120
  "kind": "text",
2158
- "text": " parameter\nto register lifecycle handlers that notify you when the subscription\nsucceeds or encounters an error.\n\nIf the connection drops, the client automatically attempts to reconnect\nand re-subscribe. The "
2121
+ "text": " parameter to register handlers that run whenever the subscription succeeds or generates an error. For some errors, the subscription is re-attempted automatically. The "
2159
2122
  },
2160
2123
  {
2161
2124
  "kind": "code",
2162
- "text": "`onSubscribed`"
2125
+ "text": "`onSubscribed()`"
2163
2126
  },
2164
2127
  {
2165
2128
  "kind": "text",
2166
- "text": " handler fires again on each\nsuccessful re-subscription."
2129
+ "text": " handler runs on every successful re-subscription."
2167
2130
  }
2168
2131
  ],
2169
2132
  "blockTags": [
@@ -2172,11 +2135,11 @@
2172
2135
  "content": [
2173
2136
  {
2174
2137
  "kind": "text",
2175
- "text": "Manual client (self-hosted / explicit auth)\n"
2138
+ "text": "Subscribe to a channel\n"
2176
2139
  },
2177
2140
  {
2178
2141
  "kind": "code",
2179
- "text": "```ts\nimport { subscriber } from '@wix/realtime';\nimport { createClient, AppStrategy } from '@wix/sdk';\n\nconst client = createClient({\n modules: { subscriber },\n auth: AppStrategy({ appId, appSecret, instanceId }),\n});\n\nconst subscriptionId = client.subscriber.subscribe(\n { name: 'my-channel' },\n (message, channel) => {\n console.log('Received:', message.payload);\n },\n {\n onSubscribed: (id, isSynced) => console.log('Subscribed', id),\n onSubscriptionError: (error, id) => console.error('Error', error),\n },\n);\n```"
2142
+ "text": "```ts\nimport { subscriber } from '@wix/realtime';\n\nconst subscriptionId = subscriber.subscribe(\n { name: 'my-channel' },\n (message, channel) => {\n console.log('Received:', message.payload);\n },\n);\n```"
2180
2143
  }
2181
2144
  ]
2182
2145
  },
@@ -2185,11 +2148,11 @@
2185
2148
  "content": [
2186
2149
  {
2187
2150
  "kind": "text",
2188
- "text": "Contextual client (Wix-hosted)\n"
2151
+ "text": "Subscribe to a channel: Self-hosted\n"
2189
2152
  },
2190
2153
  {
2191
2154
  "kind": "code",
2192
- "text": "```ts\nimport { subscriber } from '@wix/realtime';\n\nconst subscriptionId = subscriber.subscribe(\n { name: 'my-channel' },\n (message, channel) => {\n console.log('Received:', message.payload);\n },\n);\n```"
2155
+ "text": "```ts\nimport { createClient } from '@wix/sdk';\nimport { subscriber } from '@wix/realtime';\n\n// Import the auth strategy for the relevant access type\n// Import the relevant host module if needed\n\nconst client = createClient({\n modules: { subscriber },\n // Include the auth strategy and host as relevant\n});\n\nconst subscriptionId = client.subscriber.subscribe(\n { name: 'my-channel' },\n (message, channel) => {\n console.log('Received:', message.payload);\n },\n {\n onSubscribed: (id, isSynced) => console.log('Subscribed', id),\n onSubscriptionError: (error, id) => console.error('Error', error),\n },\n);\n```"
2193
2156
  }
2194
2157
  ]
2195
2158
  }
@@ -2277,7 +2240,7 @@
2277
2240
  "summary": [
2278
2241
  {
2279
2242
  "kind": "text",
2280
- "text": "Subscribes to a channel or channel resource.\n\nThe method returns a subscription ID immediately. The connection is\nestablished asynchronously in the background. Use the "
2243
+ "text": "Subscribes to a channel or resource.\n\nThe method attempts to establish a subscription to the specified channel or resource. While the subscription is attempted asynchronously, the method returns the subscription ID immediately.\n\nUse the "
2281
2244
  },
2282
2245
  {
2283
2246
  "kind": "code",
@@ -2285,15 +2248,15 @@
2285
2248
  },
2286
2249
  {
2287
2250
  "kind": "text",
2288
- "text": " parameter\nto register lifecycle handlers that notify you when the subscription\nsucceeds or encounters an error.\n\nIf the connection drops, the client automatically attempts to reconnect\nand re-subscribe. The "
2251
+ "text": " parameter to register handlers that run whenever the subscription succeeds or generates an error. For some errors, the subscription is re-attempted automatically. The "
2289
2252
  },
2290
2253
  {
2291
2254
  "kind": "code",
2292
- "text": "`onSubscribed`"
2255
+ "text": "`onSubscribed()`"
2293
2256
  },
2294
2257
  {
2295
2258
  "kind": "text",
2296
- "text": " handler fires again on each\nsuccessful re-subscription."
2259
+ "text": " handler runs on every successful re-subscription."
2297
2260
  }
2298
2261
  ],
2299
2262
  "blockTags": [
@@ -2302,11 +2265,11 @@
2302
2265
  "content": [
2303
2266
  {
2304
2267
  "kind": "text",
2305
- "text": "Manual client (self-hosted / explicit auth)\n"
2268
+ "text": "Subscribe to a channel\n"
2306
2269
  },
2307
2270
  {
2308
2271
  "kind": "code",
2309
- "text": "```ts\nimport { subscriber } from '@wix/realtime';\nimport { createClient, AppStrategy } from '@wix/sdk';\n\nconst client = createClient({\n modules: { subscriber },\n auth: AppStrategy({ appId, appSecret, instanceId }),\n});\n\nconst subscriptionId = client.subscriber.subscribe(\n { name: 'my-channel' },\n (message, channel) => {\n console.log('Received:', message.payload);\n },\n {\n onSubscribed: (id, isSynced) => console.log('Subscribed', id),\n onSubscriptionError: (error, id) => console.error('Error', error),\n },\n);\n```"
2272
+ "text": "```ts\nimport { subscriber } from '@wix/realtime';\n\nconst subscriptionId = subscriber.subscribe(\n { name: 'my-channel' },\n (message, channel) => {\n console.log('Received:', message.payload);\n },\n);\n```"
2310
2273
  }
2311
2274
  ]
2312
2275
  },
@@ -2315,11 +2278,11 @@
2315
2278
  "content": [
2316
2279
  {
2317
2280
  "kind": "text",
2318
- "text": "Contextual client (Wix-hosted)\n"
2281
+ "text": "Subscribe to a channel: Self-hosted\n"
2319
2282
  },
2320
2283
  {
2321
2284
  "kind": "code",
2322
- "text": "```ts\nimport { subscriber } from '@wix/realtime';\n\nconst subscriptionId = subscriber.subscribe(\n { name: 'my-channel' },\n (message, channel) => {\n console.log('Received:', message.payload);\n },\n);\n```"
2285
+ "text": "```ts\nimport { createClient } from '@wix/sdk';\nimport { subscriber } from '@wix/realtime';\n\n// Import the auth strategy for the relevant access type\n// Import the relevant host module if needed\n\nconst client = createClient({\n modules: { subscriber },\n // Include the auth strategy and host as relevant\n});\n\nconst subscriptionId = client.subscriber.subscribe(\n { name: 'my-channel' },\n (message, channel) => {\n console.log('Received:', message.payload);\n },\n {\n onSubscribed: (id, isSynced) => console.log('Subscribed', id),\n onSubscriptionError: (error, id) => console.error('Error', error),\n },\n);\n```"
2323
2286
  }
2324
2287
  ]
2325
2288
  }
@@ -2372,7 +2335,7 @@
2372
2335
  "summary": [
2373
2336
  {
2374
2337
  "kind": "text",
2375
- "text": "Removes one or more subscriptions.\n\nYou can unsubscribe in three ways:\n- By "
2338
+ "text": "Removes 1 or more subscriptions.\n\nYou can unsubscribe in 3 ways:\n- By "
2376
2339
  },
2377
2340
  {
2378
2341
  "kind": "code",
@@ -2388,7 +2351,7 @@
2388
2351
  },
2389
2352
  {
2390
2353
  "kind": "text",
2391
- "text": ": removes all subscriptions to that channel or channel resource.\n- By both: removes the specific subscription, verifying it matches the channel.\n\nWhen the last subscription on a connection is removed, the connection\ncloses automatically."
2354
+ "text": ": removes all subscriptions to that channel or resource.\n- By both: removes the specific subscription, verifying it matches the channel.\n\nWhen the last subscription on a connection is removed, the connection\ncloses automatically."
2392
2355
  }
2393
2356
  ],
2394
2357
  "blockTags": [
@@ -2397,11 +2360,11 @@
2397
2360
  "content": [
2398
2361
  {
2399
2362
  "kind": "text",
2400
- "text": "Manual client (self-hosted / explicit auth)\n"
2363
+ "text": "Remove the specified subscription.\n"
2401
2364
  },
2402
2365
  {
2403
2366
  "kind": "code",
2404
- "text": "```ts\nimport { subscriber } from '@wix/realtime';\nimport { createClient, AppStrategy } from '@wix/sdk';\n\nconst client = createClient({\n modules: { subscriber },\n auth: AppStrategy({ appId, appSecret, instanceId }),\n});\n\n// Unsubscribe by subscription ID\nclient.subscriber.unsubscribe({ subscriptionId });\n\n// Unsubscribe from all subscriptions to a channel\nclient.subscriber.unsubscribe({ channel: { name: 'my-channel' } });\n```"
2367
+ "text": "```ts\nimport { subscriber } from '@wix/realtime';\n\nsubscriber.unsubscribe({ subscriptionId });\n```"
2405
2368
  }
2406
2369
  ]
2407
2370
  },
@@ -2410,11 +2373,11 @@
2410
2373
  "content": [
2411
2374
  {
2412
2375
  "kind": "text",
2413
- "text": "Contextual client (Wix-hosted)\n"
2376
+ "text": "Remove the specified subscription: Self-hosted\n"
2414
2377
  },
2415
2378
  {
2416
2379
  "kind": "code",
2417
- "text": "```ts\nimport { subscriber } from '@wix/realtime';\n\nsubscriber.unsubscribe({ subscriptionId });\n```"
2380
+ "text": "```ts\nimport { subscriber } from '@wix/realtime';\nimport { createClient } from '@wix/sdk';\n\n// Import the auth strategy for the relevant access type\n// Import the relevant host module if needed\n\nconst client = createClient({\n modules: { subscriber },\n // Include the auth strategy and host as relevant\n});\n\n// Remove the specified subscription\nclient.subscriber.unsubscribe({ subscriptionId });\n\n// Remove all subscriptions from the specified channel\nclient.subscriber.unsubscribe({ channel: { name: 'my-channel' } });\n```"
2418
2381
  }
2419
2382
  ]
2420
2383
  }
@@ -2431,7 +2394,7 @@
2431
2394
  "summary": [
2432
2395
  {
2433
2396
  "kind": "text",
2434
- "text": "Specifies what to unsubscribe from. At least one of "
2397
+ "text": "Unsubscribe information. You must specify "
2435
2398
  },
2436
2399
  {
2437
2400
  "kind": "code",
@@ -2439,7 +2402,7 @@
2439
2402
  },
2440
2403
  {
2441
2404
  "kind": "text",
2442
- "text": " or "
2405
+ "text": ", "
2443
2406
  },
2444
2407
  {
2445
2408
  "kind": "code",
@@ -2447,7 +2410,7 @@
2447
2410
  },
2448
2411
  {
2449
2412
  "kind": "text",
2450
- "text": " is required."
2413
+ "text": ", or both."
2451
2414
  }
2452
2415
  ]
2453
2416
  },
@@ -2474,7 +2437,7 @@
2474
2437
  "summary": [
2475
2438
  {
2476
2439
  "kind": "text",
2477
- "text": "Removes one or more subscriptions.\n\nYou can unsubscribe in three ways:\n- By "
2440
+ "text": "Removes 1 or more subscriptions.\n\nYou can unsubscribe in 3 ways:\n- By "
2478
2441
  },
2479
2442
  {
2480
2443
  "kind": "code",
@@ -2490,7 +2453,7 @@
2490
2453
  },
2491
2454
  {
2492
2455
  "kind": "text",
2493
- "text": ": removes all subscriptions to that channel or channel resource.\n- By both: removes the specific subscription, verifying it matches the channel.\n\nWhen the last subscription on a connection is removed, the connection\ncloses automatically."
2456
+ "text": ": removes all subscriptions to that channel or resource.\n- By both: removes the specific subscription, verifying it matches the channel.\n\nWhen the last subscription on a connection is removed, the connection\ncloses automatically."
2494
2457
  }
2495
2458
  ],
2496
2459
  "blockTags": [
@@ -2499,11 +2462,11 @@
2499
2462
  "content": [
2500
2463
  {
2501
2464
  "kind": "text",
2502
- "text": "Manual client (self-hosted / explicit auth)\n"
2465
+ "text": "Remove the specified subscription.\n"
2503
2466
  },
2504
2467
  {
2505
2468
  "kind": "code",
2506
- "text": "```ts\nimport { subscriber } from '@wix/realtime';\nimport { createClient, AppStrategy } from '@wix/sdk';\n\nconst client = createClient({\n modules: { subscriber },\n auth: AppStrategy({ appId, appSecret, instanceId }),\n});\n\n// Unsubscribe by subscription ID\nclient.subscriber.unsubscribe({ subscriptionId });\n\n// Unsubscribe from all subscriptions to a channel\nclient.subscriber.unsubscribe({ channel: { name: 'my-channel' } });\n```"
2469
+ "text": "```ts\nimport { subscriber } from '@wix/realtime';\n\nsubscriber.unsubscribe({ subscriptionId });\n```"
2507
2470
  }
2508
2471
  ]
2509
2472
  },
@@ -2512,11 +2475,11 @@
2512
2475
  "content": [
2513
2476
  {
2514
2477
  "kind": "text",
2515
- "text": "Contextual client (Wix-hosted)\n"
2478
+ "text": "Remove the specified subscription: Self-hosted\n"
2516
2479
  },
2517
2480
  {
2518
2481
  "kind": "code",
2519
- "text": "```ts\nimport { subscriber } from '@wix/realtime';\n\nsubscriber.unsubscribe({ subscriptionId });\n```"
2482
+ "text": "```ts\nimport { subscriber } from '@wix/realtime';\nimport { createClient } from '@wix/sdk';\n\n// Import the auth strategy for the relevant access type\n// Import the relevant host module if needed\n\nconst client = createClient({\n modules: { subscriber },\n // Include the auth strategy and host as relevant\n});\n\n// Remove the specified subscription\nclient.subscriber.unsubscribe({ subscriptionId });\n\n// Remove all subscriptions from the specified channel\nclient.subscriber.unsubscribe({ channel: { name: 'my-channel' } });\n```"
2520
2483
  }
2521
2484
  ]
2522
2485
  }
@@ -2573,7 +2536,7 @@
2573
2536
  "summary": [
2574
2537
  {
2575
2538
  "kind": "text",
2576
- "text": "Error codes for realtime errors."
2539
+ "text": "Error codes."
2577
2540
  }
2578
2541
  ]
2579
2542
  },
@@ -2588,7 +2551,7 @@
2588
2551
  "summary": [
2589
2552
  {
2590
2553
  "kind": "text",
2591
- "text": "The input is invalid. For example, a channel name with unsupported characters."
2554
+ "text": "Invalid input such as a channel name with unsupported characters."
2592
2555
  }
2593
2556
  ]
2594
2557
  },
@@ -2607,7 +2570,7 @@
2607
2570
  "summary": [
2608
2571
  {
2609
2572
  "kind": "text",
2610
- "text": "A connection attempt failed. The client keeps retrying automatically with exponential backoff."
2573
+ "text": "Connection attempt failed. Wix automatically attempts to establish the subscription."
2611
2574
  }
2612
2575
  ]
2613
2576
  },
@@ -2626,15 +2589,15 @@
2626
2589
  "summary": [
2627
2590
  {
2628
2591
  "kind": "text",
2629
- "text": "The connection was closed, either intentionally or due to an error. Check "
2592
+ "text": "Connection closed intentionally or due to an error. Check "
2630
2593
  },
2631
2594
  {
2632
2595
  "kind": "code",
2633
- "text": "`recoverable`"
2596
+ "text": "`error.recoverable`"
2634
2597
  },
2635
2598
  {
2636
2599
  "kind": "text",
2637
- "text": " to determine whether the client is attempting to reconnect."
2600
+ "text": " to determine whether the client is attempting to reconnect. Learn more about [realtime SDK errors](ADDLINK)."
2638
2601
  }
2639
2602
  ]
2640
2603
  },
@@ -2653,7 +2616,7 @@
2653
2616
  "summary": [
2654
2617
  {
2655
2618
  "kind": "text",
2656
- "text": "The subscription request was rejected by the server. For example, due to an authorization failure. This error is non-recoverable."
2619
+ "text": "Subscription request rejected, for example, due to an authorization failure. This error is non-recoverable."
2657
2620
  }
2658
2621
  ]
2659
2622
  },
@@ -2685,7 +2648,7 @@
2685
2648
  "summary": [
2686
2649
  {
2687
2650
  "kind": "text",
2688
- "text": "An error related to a realtime subscription or connection."
2651
+ "text": "Error thrown by a subscription or connection."
2689
2652
  }
2690
2653
  ]
2691
2654
  },
@@ -2832,7 +2795,7 @@
2832
2795
  "summary": [
2833
2796
  {
2834
2797
  "kind": "text",
2835
- "text": "Channel related to the error, if applicable."
2798
+ "text": "Channel that caused the error."
2836
2799
  }
2837
2800
  ]
2838
2801
  },
@@ -2853,7 +2816,7 @@
2853
2816
  "summary": [
2854
2817
  {
2855
2818
  "kind": "text",
2856
- "text": "Error code indicating the type of error."
2819
+ "text": "Error code."
2857
2820
  }
2858
2821
  ]
2859
2822
  },
@@ -2876,7 +2839,7 @@
2876
2839
  "summary": [
2877
2840
  {
2878
2841
  "kind": "text",
2879
- "text": "Whether the error is recoverable. When "
2842
+ "text": "Whether the error is automatically recoverable.\n\nWhen "
2880
2843
  },
2881
2844
  {
2882
2845
  "kind": "code",
@@ -2884,7 +2847,7 @@
2884
2847
  },
2885
2848
  {
2886
2849
  "kind": "text",
2887
- "text": ", the client is\nautomatically attempting to reconnect. When "
2850
+ "text": ", the client automatically attempts to reconnect. When "
2888
2851
  },
2889
2852
  {
2890
2853
  "kind": "code",
@@ -2892,11 +2855,15 @@
2892
2855
  },
2893
2856
  {
2894
2857
  "kind": "text",
2895
- "text": ", the subscription\nmust be re-created manually.\n\nDefault: "
2858
+ "text": ", you must attempt to re-subscribe manually.\n\nDefault: "
2896
2859
  },
2897
2860
  {
2898
2861
  "kind": "code",
2899
2862
  "text": "`false`"
2863
+ },
2864
+ {
2865
+ "kind": "text",
2866
+ "text": "."
2900
2867
  }
2901
2868
  ]
2902
2869
  },
@@ -2917,31 +2884,7 @@
2917
2884
  "summary": [
2918
2885
  {
2919
2886
  "kind": "text",
2920
- "text": "HTTP status code from the server response. For example, "
2921
- },
2922
- {
2923
- "kind": "code",
2924
- "text": "`401`"
2925
- },
2926
- {
2927
- "kind": "text",
2928
- "text": ", "
2929
- },
2930
- {
2931
- "kind": "code",
2932
- "text": "`403`"
2933
- },
2934
- {
2935
- "kind": "text",
2936
- "text": ", or "
2937
- },
2938
- {
2939
- "kind": "code",
2940
- "text": "`500`"
2941
- },
2942
- {
2943
- "kind": "text",
2944
- "text": ".\n\nReturned only when "
2887
+ "text": "[HTTP status code](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/troubleshooting/about-errors#http-status-codes).\n\nReturned only when "
2945
2888
  },
2946
2889
  {
2947
2890
  "kind": "code",
@@ -3006,7 +2949,7 @@
3006
2949
  "summary": [
3007
2950
  {
3008
2951
  "kind": "text",
3009
- "text": "A message received on a realtime channel."
2952
+ "text": "Message received on a channel."
3010
2953
  }
3011
2954
  ]
3012
2955
  },
@@ -3021,7 +2964,7 @@
3021
2964
  "summary": [
3022
2965
  {
3023
2966
  "kind": "text",
3024
- "text": "Message payload containing the published data.\n\nMax: 10 KB."
2967
+ "text": "Message payload that contains the published data.\n\nMax: 10 KB."
3025
2968
  }
3026
2969
  ]
3027
2970
  },
@@ -3057,7 +3000,7 @@
3057
3000
  "summary": [
3058
3001
  {
3059
3002
  "kind": "text",
3060
- "text": "Information about the user who published the message.\n\nReturned only when the publisher's identity is available."
3003
+ "text": "Publisher details.\n\nReturned only when the publisher's identity is available."
3061
3004
  }
3062
3005
  ]
3063
3006
  },
@@ -3089,7 +3032,7 @@
3089
3032
  "summary": [
3090
3033
  {
3091
3034
  "kind": "text",
3092
- "text": "Information about the user who published a message."
3035
+ "text": "Publisher details."
3093
3036
  }
3094
3037
  ]
3095
3038
  },
@@ -3104,7 +3047,7 @@
3104
3047
  "summary": [
3105
3048
  {
3106
3049
  "kind": "text",
3107
- "text": "Publisher ID."
3050
+ "text": "Publisher ID.\n\n<!-- TODO: Where does the caller get the publisher ID? -->"
3108
3051
  }
3109
3052
  ]
3110
3053
  },
@@ -3133,7 +3076,7 @@
3133
3076
  "summary": [
3134
3077
  {
3135
3078
  "kind": "text",
3136
- "text": "Optional lifecycle handlers for a subscription. Use these to respond to\nsubscription status changes, such as successful connections and errors."
3079
+ "text": "Subscription status handlers that run whenever a subscription is established, re-established, or fails."
3137
3080
  }
3138
3081
  ]
3139
3082
  },
@@ -3150,7 +3093,7 @@
3150
3093
  "summary": [
3151
3094
  {
3152
3095
  "kind": "text",
3153
- "text": "Called when the subscription is successfully established.\n\nThis handler fires on the initial subscription and again every time the\nsubscription is automatically restored after a reconnection. Make\nsure your handler is idempotent.\n\nThe "
3096
+ "text": "Runs whenever the subscription is successfully established or re-established after a prior failure. To avoid unnecessary actions, make the handler idempotent.\n\nThe "
3154
3097
  },
3155
3098
  {
3156
3099
  "kind": "code",
@@ -3158,31 +3101,7 @@
3158
3101
  },
3159
3102
  {
3160
3103
  "kind": "text",
3161
- "text": " parameter indicates whether the server restored\nmissed messages since the last disconnection:\n\n- **First subscription**: always "
3162
- },
3163
- {
3164
- "kind": "code",
3165
- "text": "`false`"
3166
- },
3167
- {
3168
- "kind": "text",
3169
- "text": ". The client has no prior\n message history, so the server can't restore anything. Load your\n initial state independently.\n\n- **Re-subscription after reconnect, "
3170
- },
3171
- {
3172
- "kind": "code",
3173
- "text": "`true`"
3174
- },
3175
- {
3176
- "kind": "text",
3177
- "text": "**: the server\n found the last received message and replayed everything since.\n No action needed.\n\n- **Re-subscription after reconnect, "
3178
- },
3179
- {
3180
- "kind": "code",
3181
- "text": "`false`"
3182
- },
3183
- {
3184
- "kind": "text",
3185
- "text": "**: the server\n couldn't restore missed messages (for example, they expired). Resync your\n state independently.\n\n<!-- TODO: Document server-side buffer limits for message replay. -->"
3104
+ "text": " parameter indicates whether missed messages were restored."
3186
3105
  }
3187
3106
  ],
3188
3107
  "blockTags": [
@@ -3192,7 +3111,7 @@
3192
3111
  "content": [
3193
3112
  {
3194
3113
  "kind": "text",
3195
- "text": "ID of the subscription that was established."
3114
+ "text": "ID of the subscription."
3196
3115
  }
3197
3116
  ]
3198
3117
  },
@@ -3202,7 +3121,55 @@
3202
3121
  "content": [
3203
3122
  {
3204
3123
  "kind": "text",
3205
- "text": "Whether the server successfully restored missed messages."
3124
+ "text": "Whether the server successfully restored missed messages since the last disconnection.\n\nThe value of this parameter depends on the scenario:\n\n- When subscribing for the first time, "
3125
+ },
3126
+ {
3127
+ "kind": "code",
3128
+ "text": "`isSynced`"
3129
+ },
3130
+ {
3131
+ "kind": "text",
3132
+ "text": " is "
3133
+ },
3134
+ {
3135
+ "kind": "code",
3136
+ "text": "`false`"
3137
+ },
3138
+ {
3139
+ "kind": "text",
3140
+ "text": ", as there are no prior messages to restore. In this scenario, load your initial state independently.\n\n- When re-subscribing and all messages were successfully restored, "
3141
+ },
3142
+ {
3143
+ "kind": "code",
3144
+ "text": "`isSynced`"
3145
+ },
3146
+ {
3147
+ "kind": "text",
3148
+ "text": " is "
3149
+ },
3150
+ {
3151
+ "kind": "code",
3152
+ "text": "`true`"
3153
+ },
3154
+ {
3155
+ "kind": "text",
3156
+ "text": ". No further action is necessary.\n\n- When re-subscribing but some messages weren't restored, "
3157
+ },
3158
+ {
3159
+ "kind": "code",
3160
+ "text": "`isSynced`"
3161
+ },
3162
+ {
3163
+ "kind": "text",
3164
+ "text": " is "
3165
+ },
3166
+ {
3167
+ "kind": "code",
3168
+ "text": "`false`"
3169
+ },
3170
+ {
3171
+ "kind": "text",
3172
+ "text": ". The server is unable to restore all missed messages. In this scenario, you need to resync your state independently.\n\n<!-- TODO: Document server-side buffer limits for message replay. -->"
3206
3173
  }
3207
3174
  ]
3208
3175
  }
@@ -3227,23 +3194,15 @@
3227
3194
  "summary": [
3228
3195
  {
3229
3196
  "kind": "text",
3230
- "text": "Called when a subscription error occurs.\n\nThis handler is triggered in the following scenarios:\n\n- **Subscription failed**: the subscription request was rejected (for example,\n due to an authorization failure). The error includes the HTTP\n "
3197
+ "text": "Runs when a subscription error occurs. It can run multiple times in a single session.\n\nThis handler runs in the following scenarios:\n\n- **Subscription failed**: The subscription request was rejected, for example, due to an authorization failure. This error is non-recoverable, so the subscription isn't automatically re-attempted.\n\n- **Subscription disconnected**: The connection between the subscriber and publisher was closed. Check "
3231
3198
  },
3232
3199
  {
3233
3200
  "kind": "code",
3234
- "text": "`status`"
3235
- },
3236
- {
3237
- "kind": "text",
3238
- "text": " code. This is non-recoverable and the subscription\n doesn't retry automatically.\n\n- **Disconnected**: the connection was closed. Check the "
3239
- },
3240
- {
3241
- "kind": "code",
3242
- "text": "`recoverable`"
3201
+ "text": "`error.recoverable`"
3243
3202
  },
3244
3203
  {
3245
3204
  "kind": "text",
3246
- "text": "\n flag to determine whether the client is auto-reconnecting ("
3205
+ "text": ":\n - When "
3247
3206
  },
3248
3207
  {
3249
3208
  "kind": "code",
@@ -3251,7 +3210,7 @@
3251
3210
  },
3252
3211
  {
3253
3212
  "kind": "text",
3254
- "text": ") or\n whether you need to re-create the subscription ("
3213
+ "text": ", the error is recoverable. The subscription is automatically re-attempted. No further action necessary.\n - When "
3255
3214
  },
3256
3215
  {
3257
3216
  "kind": "code",
@@ -3259,11 +3218,11 @@
3259
3218
  },
3260
3219
  {
3261
3220
  "kind": "text",
3262
- "text": ").\n\n- **Connection error**: fired on each failed reconnection attempt.\n The "
3221
+ "text": ", the error isn't recoverable. Establish the subscription again.\n\n- **Connection error**: Runs on each failed subscription attempt. The "
3263
3222
  },
3264
3223
  {
3265
3224
  "kind": "code",
3266
- "text": "`recoverable`"
3225
+ "text": "`error.recoverable`"
3267
3226
  },
3268
3227
  {
3269
3228
  "kind": "text",
@@ -3275,23 +3234,7 @@
3275
3234
  },
3276
3235
  {
3277
3236
  "kind": "text",
3278
- "text": " for these errors because the\n client keeps retrying with exponential backoff.\n\nCheck "
3279
- },
3280
- {
3281
- "kind": "code",
3282
- "text": "`error.recoverable`"
3283
- },
3284
- {
3285
- "kind": "text",
3286
- "text": " to distinguish transient errors from permanent\nfailures. This handler may fire multiple times during a single session.\nA typical recovery flow looks like:\n"
3287
- },
3288
- {
3289
- "kind": "code",
3290
- "text": "`subscribed → error (recoverable) → error (recoverable) → subscribed`"
3291
- },
3292
- {
3293
- "kind": "text",
3294
- "text": "."
3237
+ "text": ", as the subscription is re-established."
3295
3238
  }
3296
3239
  ],
3297
3240
  "blockTags": [
@@ -3301,7 +3244,23 @@
3301
3244
  "content": [
3302
3245
  {
3303
3246
  "kind": "text",
3304
- "text": "The error that occurred."
3247
+ "text": "Error that occurred. Check "
3248
+ },
3249
+ {
3250
+ "kind": "code",
3251
+ "text": "`errorCode`"
3252
+ },
3253
+ {
3254
+ "kind": "text",
3255
+ "text": " and "
3256
+ },
3257
+ {
3258
+ "kind": "code",
3259
+ "text": "`recoverable`"
3260
+ },
3261
+ {
3262
+ "kind": "text",
3263
+ "text": " to determine the type and whether manual action is required."
3305
3264
  }
3306
3265
  ]
3307
3266
  },
@@ -3311,7 +3270,7 @@
3311
3270
  "content": [
3312
3271
  {
3313
3272
  "kind": "text",
3314
- "text": "ID of the affected subscription."
3273
+ "text": "ID of the subscription that generated the error."
3315
3274
  }
3316
3275
  ]
3317
3276
  }
@@ -3345,7 +3304,7 @@
3345
3304
  "summary": [
3346
3305
  {
3347
3306
  "kind": "text",
3348
- "text": "Options for specifying what to unsubscribe from.\n\nSpecify "
3307
+ "text": "Unsubscribe options. Specify "
3349
3308
  },
3350
3309
  {
3351
3310
  "kind": "code",
@@ -3353,7 +3312,7 @@
3353
3312
  },
3354
3313
  {
3355
3314
  "kind": "text",
3356
- "text": " to remove all subscriptions to a channel, "
3315
+ "text": ", "
3357
3316
  },
3358
3317
  {
3359
3318
  "kind": "code",
@@ -3361,15 +3320,15 @@
3361
3320
  },
3362
3321
  {
3363
3322
  "kind": "text",
3364
- "text": " to remove\na single subscription, or both to remove a specific subscription with channel verification.\nAt least one of "
3323
+ "text": ", or both:\n\n- To remove all subscriptions from a channel, specify the channel in "
3365
3324
  },
3366
3325
  {
3367
3326
  "kind": "code",
3368
- "text": "`channel`"
3327
+ "text": "`channel.name`"
3369
3328
  },
3370
3329
  {
3371
3330
  "kind": "text",
3372
- "text": " or "
3331
+ "text": ".\n- To remove a single subscription, specify the "
3373
3332
  },
3374
3333
  {
3375
3334
  "kind": "code",
@@ -3377,7 +3336,7 @@
3377
3336
  },
3378
3337
  {
3379
3338
  "kind": "text",
3380
- "text": " is required."
3339
+ "text": ".\n- To remove a single subscription with channel verification, specify both. This removes the specified subscription only if it listens to the specified channel."
3381
3340
  }
3382
3341
  ]
3383
3342
  },
@@ -3394,15 +3353,7 @@
3394
3353
  "summary": [
3395
3354
  {
3396
3355
  "kind": "text",
3397
- "text": "Channel to unsubscribe from. When specified without "
3398
- },
3399
- {
3400
- "kind": "code",
3401
- "text": "`subscriptionId`"
3402
- },
3403
- {
3404
- "kind": "text",
3405
- "text": ",\nall subscriptions to this channel are removed."
3356
+ "text": "Channel or resource to unsubscribe from.\n\nWhen empty, the subscription is removed without verifying that it belongs to the channel."
3406
3357
  }
3407
3358
  ]
3408
3359
  },
@@ -3425,15 +3376,7 @@
3425
3376
  "summary": [
3426
3377
  {
3427
3378
  "kind": "text",
3428
- "text": "ID of the subscription to remove. When specified without "
3429
- },
3430
- {
3431
- "kind": "code",
3432
- "text": "`channel`"
3433
- },
3434
- {
3435
- "kind": "text",
3436
- "text": ",\nthe specific subscription is removed regardless of its channel."
3379
+ "text": "ID of the subscription to remove.\n\nWhen empty, all subscriptions to the specified channel are removed."
3437
3380
  }
3438
3381
  ]
3439
3382
  },
@@ -3478,7 +3421,7 @@
3478
3421
  "summary": [
3479
3422
  {
3480
3423
  "kind": "text",
3481
- "text": "Callback that runs when a message is received on a subscribed channel or channel resource."
3424
+ "text": "Runs when a message is published to a channel or resource the subscriber listens to."
3482
3425
  }
3483
3426
  ]
3484
3427
  },
@@ -3493,7 +3436,7 @@
3493
3436
  "summary": [
3494
3437
  {
3495
3438
  "kind": "text",
3496
- "text": "The received message, including the payload and optional publisher information."
3439
+ "text": "Published message."
3497
3440
  }
3498
3441
  ]
3499
3442
  },
@@ -3514,7 +3457,7 @@
3514
3457
  "summary": [
3515
3458
  {
3516
3459
  "kind": "text",
3517
- "text": "The channel the message was received on."
3460
+ "text": "Channel the message was published to."
3518
3461
  }
3519
3462
  ]
3520
3463
  },
@@ -3560,7 +3503,7 @@
3560
3503
  "summary": [
3561
3504
  {
3562
3505
  "kind": "text",
3563
- "text": "Callback that runs when a subscription error occurs."
3506
+ "text": "Runs when a subscription error occurs."
3564
3507
  }
3565
3508
  ]
3566
3509
  },
@@ -3575,7 +3518,7 @@
3575
3518
  "summary": [
3576
3519
  {
3577
3520
  "kind": "text",
3578
- "text": "The error that occurred."
3521
+ "text": "Error that occurred."
3579
3522
  }
3580
3523
  ]
3581
3524
  },
@@ -3596,7 +3539,7 @@
3596
3539
  "summary": [
3597
3540
  {
3598
3541
  "kind": "text",
3599
- "text": "ID of the affected subscription."
3542
+ "text": "ID of the subscription that generated the error."
3600
3543
  }
3601
3544
  ]
3602
3545
  },
@@ -3640,7 +3583,15 @@
3640
3583
  "summary": [
3641
3584
  {
3642
3585
  "kind": "text",
3643
- "text": "Callback that runs when a subscription is successfully established or re-established after a reconnection."
3586
+ "text": "Runs when a subscription is successfully established or re-established.\n\nWhen a subscription fails and is re-established, the subscriber might not receive all messages published during the failure. The "
3587
+ },
3588
+ {
3589
+ "kind": "code",
3590
+ "text": "`isSynced`"
3591
+ },
3592
+ {
3593
+ "kind": "text",
3594
+ "text": " flag indicates whether all missed messages were successfully delivered.\n\nLearn more about [realtime SDK errors](ADDLINK).\n<!-- TODO: Document server-side buffer limits for message replay. -->"
3644
3595
  }
3645
3596
  ]
3646
3597
  },
@@ -3655,7 +3606,7 @@
3655
3606
  "summary": [
3656
3607
  {
3657
3608
  "kind": "text",
3658
- "text": "ID of the subscription."
3609
+ "text": "Subscription ID."
3659
3610
  }
3660
3611
  ]
3661
3612
  },
@@ -3674,7 +3625,7 @@
3674
3625
  "summary": [
3675
3626
  {
3676
3627
  "kind": "text",
3677
- "text": "Whether the server successfully restored missed messages since the last disconnection. <!-- TODO: Document server-side buffer limits for message replay. -->"
3628
+ "text": "Whether the message history was fully restored."
3678
3629
  }
3679
3630
  ]
3680
3631
  },
@@ -3743,11 +3694,11 @@
3743
3694
  "symbolIdMap": {}
3744
3695
  },
3745
3696
  "appendices": {
3746
- "/site": [
3697
+ "/": [
3747
3698
  {
3748
3699
  "type": "GUIDE",
3749
3700
  "title": "Introduction",
3750
- "src": "# Introduction\n\n> **Note:** This API is only intended for use in [site development](https://dev.wix.com/docs/sdk/articles/get-started/about-site-development).\n\nUsing the Realtime API you can create channels and channel resources where messages\ncan be published. Site visitors who subscribe to a channel receive the\nmessages published to that channel. When a message is received you can handle the message any\nway you choose, such as displaying the contents of the message or changing the state\nof page elements depending on the contents of the message. You can also manage the\npermissions of who can read from specific channels.\n\nThe `@wix/realtime` module is used in conjunction with the [`@wix/site-realtime`](https://dev.wix.com/docs/sdk/frontend-modules/site-realtime/introduction) module.\n\nGet hands-on experience with the Realtime API on our [Hello Realtime](https://www.wix.com/velo/example/hello-realtime) example page.\n\nTypical uses of the Realtime API include implementing a messaging system or\nas an alternative to using a polling mechanism.\n\nThe Realtime API uses the following terminology:\n\n+ **Channel**: A specific channel on which messages are published. Each channel\n has a unique name. Site visitors can subscribe to a channel to receive the \n messages that are published on it. When site visitors subscribe to a channel, they do not \n receive messages published to a resource on that same channel.\n+ **Channel resource**: A subchannel on which messages are published. Subchannels\n can share a name with a channel and other subchannels, but they have a unique\n resource ID. When site visitors subscribe to a channel resource, they do not \n receive messages published to that same channel without a specified resource.\n Channel resources inherit their parent channel's permissions, unless specified\n otherwise.\n+ **Message**: A message published on a channel or channel resource. A message can\n be of any type, such as a string, number, or object. Channel subscribers receive\n the messages published on the channel.\n+ **Publish**: Sending a message over a channel or channel resource.\n+ **Subscribe**: A site visitor subscribes to receive the messages published on a \n channel or channel resource.\n+ **Permissions router**: The permissions router is used to define the permissions\n you want to grant to subscribers on channels and channel resources.\n+ **Permissions handler**: Handles a permissions check for a specific user on a \n specific channel or channel resource.\n\nFor a tutorial on using the Realtime API, see \n[Sending Messages with the Realtime API](https://dev.wix.com/docs/develop-websites/articles/code-tutorials/wix-editor-elements/sending-messages-with-the-realtime-api).\n"
3701
+ "src": "---\narticleType: intro\n---\n\n# About the Realtime APIs\n\nThe Realtime APIs let you send and receive messages between a site backend and connected clients in real time. When a backend service publishes messages to a channel, clients subscribed to that channel receive them instantly.\n\nWith the Realtime APIs, you can:\n\n- Publish messages from the backend to channels and channel resources.\n- Subscribe to channels and resources to receive messages on connected clients.\n- Control which subscribers receive messages on specific channels or channel resources.\n\nThe Realtime APIs consist of the following modules that work together:\n\n- [**Publisher**](ADDLINK): Backend module that sends messages to channels.\n- [**Site**](ADDLINK): Backend module that manages subscriber permissions.\n- [**Subscriber**](ADDLINK): Client module that listens to channels and receives messages.\n\n## How the modules work together\n\nThe Publisher sends a message to a channel or channel resource. The Site module checks whether each subscriber has permission to listen on that channel. Subscribers that have the appropriate permissions receive the message in real time.\n\nA typical flow looks like this:\n\n1. Define permissions in the **realtime-permissions.js** in the site's backend using the [Site API](ADDLINK).\n2. A client subscribes to a channel or channel resource using the [Subscriber API](ADDLINK).\n3. The `realtime_check_permission` hook checks the subscriber's permissions.\n4. The [Publisher](ADDLINK) publishes a message to the channel.\n5. The subscriber receives the message.\n\n## Channels and channel resources\n\nChannels are the mechanism by which publishers send messages to subscribers. Each channel has a unique name and can contain resources that act as sub-channels. Clients can subscribe to a channel or resource. When a publisher sends a message, subscribers receive the messages instantly if they have the appropriate permissions.\n\nChannels and resources are strictly isolated: subscribing to a channel doesn't include messages published to a resource on that channel, and subscribing to a resource doesn't include messages published to the parent channel.\n\n## Publisher\n\nThe [Publisher API](ADDLINK) is a backend module that sends messages to subscribers listening to the specified channel or resource.\n\nLearn more about [publishing messages](ADDLINK).\n\n## Site\n\nThe [Site API](ADDLINK) controls subscriber permissions. It determines which subscribers can receive messages on specific channels and resources.\n\nLearn more about [permissions in the Site API](ADDLINK).\n\n<!-- ### Permissions\n\nPermissions can be set at the channel level or the resource level. They determine whether subscribers can receive messages published to that channel or resource. \n\nYou can define permissions by adding a **realtime-permissions.js** file in a site's backend and setting up the [`realtime_check_permission` hook](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/realtime-check-permission). You can include all permissions logic directly in the hook, or use the [Permissions Router API](ADDLINK) to organize permissions logic per channel and resource. \n\nPermissions follow a cascading pattern:\n\n- When the specified resource [doesn't have a permissions handler](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/add), the handler for its parent channel runs. \n- When the specified channel doesn't have a permissions handler, the [default permissions handler](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/default) runs. \n- When no default handler is set, all subscribers receive the default permissions of `{\"read\": true}`.\n\nLearn more about [setting up permissions](ADDLINK). -->\n\n## Subscribers\n\nA subscriber is a client that listens to a channel or resource. When a message is published to a channel or resource, all subscribers with [the appropriate permissions](ADDLINK) receive the message. \n\nYou can set up dedicated handlers for incoming messages, subscription successes, and subscription failures.\n\nLearn more about the [Subscriber API](ADDLINK).\n\n<!-- ### Subscription lifecycle\n\nWhile subscribing is asynchronous, the `subscribe()` method returns a subscription ID immediately, but the connection is established in the background. Subscribers can use the subscription ID to [unsubscribe](ADDLINK) at a later time. \n\nYou can register lifecycle handlers to respond when the subscription succeeds or fails. The [`onSubscribed` handler](ADDLINK) runs on every successful connection, including automatic re-subscriptions attempted after network interruptions. The [`onSubscriptionError` handler](ADDLINK) runs whenever an error occurs. \n\nLearn more about the [Subscriber API](ADDLINK).\n\n### Subscription errors\n\nSubscription errors are caused by the subscription being rejected or by connection or reconnection failures. While some errors are automatically recoverable, some require manual handling. \n\nLearn more about [handling subscription errors](ADDLINK). -->\n\n## Before you begin\n\nIt's important to note the following points before starting to code:\n\n- Messages are ephemeral. They don't persist across sessions.\n- When previewing the site, `read` permissions are always `true`.\n<!-- TODO: Document channel/subscription limits per site/app. -->\n\n## Use cases\n\n- [Send notifications to connected clients](ADDLINK).\n- [Broadcast data updates in real time](ADDLINK).\n- [Push state changes to a live dashboard](ADDLINK).\n\n## Terminology\n\n- **Channel**: Named broadcast channel that publishers send messages to and subscribers listen on.\n- **Resource**: Isolated sub-channel in a channel. Messages on a resource are isolated from messages on its parent channel.\n- **Message**: Data published to a channel or resource.\n- **Publisher**: Service that sends messages to subscribers.\n- **Subscriber**: Client that listens for messages on a channel or resource.\n- **Subscription**: Active connection between a subscriber and a channel or resource, identified by a subscription ID.\n\n"
3751
3702
  },
3752
3703
  {
3753
3704
  "type": "GUIDE",
@@ -3755,6 +3706,27 @@
3755
3706
  "src": "# Setup\n\n@package_metadata:@wix/realtime\n\nTo use the Realtime API, install the `@wix/realtime` package.\n\n#### Install the package\n\nFollow the installation instructions for your development environment.\n\n| Development environment | Installation method |\n|--|--|\n| Wix sites (editor or IDE) | Use the [package manager](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/packages/work-with-npm-packages-in-the-editor). |\n| Wix sites (local IDE) | Run ` wix install @wix/realtime` using the [Wix CLI](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/packages/work-with-npm-packages-with-the-wix-cli).|\n\n#### Import the package\n\nTo import the package in your code:\n\n```js\nimport { site } from `@wix/realtime`;\n```"
3756
3707
  }
3757
3708
  ],
3709
+ "/publisher": [
3710
+ {
3711
+ "type": "GUIDE",
3712
+ "title": "Introduction",
3713
+ "src": "---\narticleType: intro\n---\n\n# About the Publisher API\n\nThe Publisher API is a backend module for sending messages to [channels and resources](ADDLINK). [Subscribers](ADDLINK) with suitable [permissions](ADDLINK) receive these messages instantly. Channels and resources are isolated, so messages sent to a channel are not published to a resource, and vice versa.\n\nLearn more [about the Realtime APIs](ADDLINK).\n\n<!-- TODO check that elevation note appears in method description -->\n<!-- TODO: Check whether this API is relevant for headless projects. -->\n\n## Before you begin\n\nIt's important to note the following points before starting to code:\n\n- Messages aren't queued. When no subscribers are listening, the message is dropped.\n- Messages don't persist across sessions.\n\n## Use cases\n\n- [Send notifications to connected clients](ADDLINK).\n- [Broadcast data updates in real time](ADDLINK).\n- [Push state changes to a live dashboard](ADDLINK).\n\n@sdk_package_setup\n"
3714
+ }
3715
+ ],
3716
+ "/subscriber": [
3717
+ {
3718
+ "type": "GUIDE",
3719
+ "title": "Introduction",
3720
+ "src": "---\narticleType: intro\n---\n\n# About the Subscriber API\n\nThe Subscriber API allows users to subscribe to [channels and resources](ADDLINK). When a [Publisher](ADDLINK) sends messages, subscribers with suitable permissions receive them in real time. Channels and resources are isolated, so messages sent to a channel aren't published to a resource, and vice versa.\n\nLearn more [about the Realtime APIs](ADDLINK).\n\nWith the Subscriber API, you can:\n\n- Subscribe or unsubscribe from a channel or resource.\n- Respond to subscription successes, connection errors, and incoming messages with dedicated handlers.\n\n## Subscription lifecycle\n\nWhile subscribing is asynchronous, the `subscribe()` method returns a subscription ID immediately, but the connection is established in the background. Subscribers can use the subscription ID to [unsubscribe](ADDLINK) at a later time. \n\nYou can register lifecycle handlers to respond when the subscription succeeds or fails. The [`onSubscribed` handler](ADDLINK) runs on every successful connection, including automatic re-subscriptions attempted after network interruptions. The [`onSubscriptionError` handler](ADDLINK) runs whenever an error occurs.\n\n### Unsubscribing\n\nYou can unsubscribe in the following ways:\n\n- By `subscriptionId`: Removes a single subscription.\n- By `channel`: Removes all subscriptions to that channel or resource.\n- By both: Removes the specific subscription, verifying it matches the specified channel or resource. If it doesn't, the subscription isn't removed.\n\nWhen the last subscription on a connection is removed, the connection closes automatically.\n\n## Reconnection and message sync\n\nIf the connection drops, the client automatically attempts to reconnect and re-subscribe. When subscribing or re-subscribing, the `isSynced` parameter of the `onSubscribed()` hook indicates whether all missed messages were successfully restored, or whether manual the subscriber needs to take further action. \n\nLearn more about [subscribing](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/subscribe) to a channel or resource.\n\n<!-- TODO: Document server-side buffer limits for message replay. -->\n\n## Subscription errors\n\nSubscription errors are caused by the subscription being rejected or by connection failures. Each error includes `errorCode` and `recoverable` properties that indicate the error type and whether the client is automatically retrying.\n\nLearn more about how the [`subscribe()`](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/subscriber/subscribe) method handles subscription errors.\n\n## Before you begin\n\nIt's important to note the following points before starting to code:\n\n- Subscriptions are ephemeral. They don't persist across sessions.\n- Closing a browser tab removes all its subscriptions.\n- Permissions are checked when a subscription is first established. When a subscriber doesn't have `read` permission on the channel, their subscription fails.\n<!-- TODO: Document channel/subscription limits per site/app. -->\n\n## Use cases\n\n- [Send notifications to connected clients](ADDLINK).\n- [Broadcast data updates in real time](ADDLINK).\n- [Push state changes to a live dashboard](ADDLINK).\n\n## Terminology\n\n- **Subscription**: An active connection between a client and a channel or resource, identified by a subscription ID.\n- **Subscription ID**: A unique identifier returned by `subscribe()`. Use it to unsubscribe or track lifecycle events.\n\n@sdk_package_setup\n"
3721
+ }
3722
+ ],
3723
+ "/site": [
3724
+ {
3725
+ "type": "GUIDE",
3726
+ "title": "Introduction",
3727
+ "src": "---\narticleType: intro\n---\n\n# About the Site API\n\nThe Site API lets you control subscriber permissions for the [Realtime APIs](ADDLINK). It determines which [subscribers](ADDLINK) can receive messages on specific [channels and resources](ADDLINK).\n\nTo define permissions, set up the [`realtime_check_permission` hook](ADDLINK) in the **realtime-permissions.js** file in a site's backend. You can include all permissions logic directly in the hook, or use the [Permissions Router](ADDLINK) to organize permissions logic per channel and resource.\n\nWith the Site API, you can:\n\n- Define the `realtime_check_permission` hook to control subscriber access.\n- Use the [Permissions Router](ADDLINK) to organize permission logic per channel or resource.\n\n## Before you begin\n\nIt's important to note the following points before starting to code:\n\n- In Wix Studio, you must create a **realtime-permissions.js** file in a site's backend, even if the `realtime_check_permission` isn't defined. Without the file, subscriptions fail.\n- When the `realtime_check_permission` hook isn't defined, all subscribers receive the default permissions of `{\"read\": true}`.\n- When previewing a site, `read` permissions are always `true`.\n- Learn more about [permissions in the realtime SDK](ADDLINK).\n\n## Use cases\n\n- [Restrict channels to logged-in members](ADDLINK).\n\n@sdk_package_setup"
3728
+ }
3729
+ ],
3758
3730
  "/site/publish": [
3759
3731
  {
3760
3732
  "type": "EXAMPLE",
@@ -3810,7 +3782,7 @@
3810
3782
  {
3811
3783
  "type": "GUIDE",
3812
3784
  "title": "Introduction",
3813
- "src": "# Introduction\n\nUse the permissions router to define the permissions you want to grant to subscribers\non channels or channel resources. You can set permissions on the channel and channel\nresource level. If you do not define permissions for a particular channel resource,\nthat resource inherits the permissions of its parent channel.\n\nTypically you use the permissions router in the **realtime-permissions.js** file in\nyour site's backend to:\n\n+ Set default permissions for all channels and channel resources where no explicit\n permissions are defined.\n+ Add permissions logic for specific channels or channel resources.\n+ Check the permissions for a specific subscriber on a specific channel.\n\n> **Note:** Although it is recommended, you do not need to use the permissions router to set permissions. You can also define all your permissions logic in the [`realtime_check_permission()`](https://dev.wix.com/docs/sdk/backend-modules/realtime/site/realtime-check-permission) function."
3785
+ "src": "---\narticleType: intro\n---\n\n# About the Permissions Router API\n\nThe 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.\n\n> **Note**: Alternatively, you can include permissions logic in the [`realtime_check_permission()`](ADDLINK) hook.\n\nLearn more about the [Site API](ADDLINK) and the [Realtime APIs](ADDLINK).\n\nWith the Permissions Router API, you can:\n\n- [Add a handler](ADDLINK) for a specific channel or resource.\n- [Set a default handler](ADDLINK) for channels that don't have explicit handlers.\n- [Check](ADDLINK) subscriber permissions.\n\n## Setting up permissions\n\nTo set up permissions:\n\n1. Create a **realtime-permissions.js** file in a site's backend.\n2. Export a `realtime_check_permission` hook. This hook runs automatically whenever a subscription is attempted.\n3. In the hook body, call `permissionsRouter.check()` to evaluate the subscriber's permissions based on the handlers you've registered.\n\n```js\nimport { permissionsRouter } from '@wix/realtime';\n\npermissionsRouter.default((channel, subscriber) => {\n return { read: true };\n});\n\nexport function realtime_check_permission(channel, subscriber) {\n return permissionsRouter.check(channel, subscriber);\n}\n```\n\n## Permission resolution\n\nPermissions can be set at the channel level or the resource level. They determine whether subscribers can receive messages published to that channel or resource.\n\nPermissions follow a cascading pattern:\n\n- When the specified resource [doesn't have a permissions handler](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/add), the handler for its parent channel runs.\n- When the specified or parent channel doesn't have a permissions handler, the [default permissions handler](https://dev.wix.com/docs/sdk/business-solutions/realtime/realtime/site/permissions-router/default) runs.\n- When no default handler is set, all subscribers receive the default permissions of `{ \"read\": true }`.\n\n## Before you begin\n\nIt's important to note the following points before starting to code:\n\n- You must create a **realtime-permissions.js** file in a site's backend. Without it, all subscriptions fail in Wix Studio.\n- When the `realtime_check_permission` hook isn't defined, all subscribers receive the default permissions of `{\"read\": true}`.\n- When previewing a site, `read` permissions are always `true`.\n\n## Use cases\n\n- [Restrict channels to logged-in members](ADDLINK).\n\n@sdk_package_setup"
3814
3786
  }
3815
3787
  ],
3816
3788
  "/site/PermissionsRouter/add": [