@thor-commerce/app-bridge-react 0.7.3 → 0.8.0

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.
package/README.md CHANGED
@@ -10,6 +10,53 @@ Repository link: [thor-email-app](https://github.com/thor-commerce/thor-email-ap
10
10
  npm install @thor-commerce/app-bridge-react
11
11
  ```
12
12
 
13
+ ## CDN Runtime
14
+
15
+ The package now also builds a standalone browser runtime that can be hosted on a CDN.
16
+
17
+ Build it with:
18
+
19
+ ```bash
20
+ pnpm build
21
+ ```
22
+
23
+ The CDN-friendly artifact is:
24
+
25
+ ```txt
26
+ dist/thor-app-bridge.js
27
+ ```
28
+
29
+ You can load it before your app bundle:
30
+
31
+ ```html
32
+ <script
33
+ src="https://cdn.example.com/thor-app-bridge/thor-app-bridge.js"
34
+ data-client-id="your-client-id"
35
+ data-target-origin="https://dashboard.thorcommerce.com"
36
+ ></script>
37
+ ```
38
+
39
+ For Shopify-like markup, the script also accepts `data-api-key`, but the value must still be the public Thor `clientId`, not the `clientSecret`.
40
+
41
+ That script:
42
+
43
+ - bootstraps a singleton runtime before React mounts
44
+ - patches same-origin `fetch` to attach Thor session tokens
45
+ - intercepts in-app navigation and reports sanitized paths back to the dashboard
46
+ - keeps embedded launch params on the iframe document URL
47
+
48
+ If you do not want auto-init, omit the data attributes and initialize it manually:
49
+
50
+ ```html
51
+ <script src="https://cdn.example.com/thor-app-bridge/thor-app-bridge.js"></script>
52
+ <script>
53
+ window.ThorAppBridge.init({
54
+ clientId: "your-client-id",
55
+ targetOrigin: "https://dashboard.thorcommerce.com",
56
+ });
57
+ </script>
58
+ ```
59
+
13
60
  ## Core Usage
14
61
 
15
62
  ```ts
@@ -65,6 +112,7 @@ export function Providers({ children }: { children: React.ReactNode }) {
65
112
  `ReactRouterAppBridgeProvider` and `NextAppBridgeProvider` automatically:
66
113
 
67
114
  - create the bridge on the client
115
+ - attach to the singleton runtime when the browser script already initialized it
68
116
  - send `app:ready`
69
117
  - emit `navigation:update` when the route changes
70
118
  - listen for `navigation:go` and push the app to the requested route