Truv recommends the default
https://cdn.truv.com/bridge.js without a pinned version. It always serves the latest version, so you get fixes without changing your code. A pinned version requires you to update it within 6 months of its release.<script> tag or with the @truv/bridge and @truv/react packages.
Get the latest version
Every Bridge release publishes a manifest. Fetch the manifest of the latest release:
Each version also keeps its own manifest at
https://cdn.truv.com/bridge/vX.X.X/manifest.json.
Add the script
Copyurl and integrity from the manifest into the script tag:
TruvBridge.init() as usual. See Embedded Orders or Widget-only.
Use the npm packages
Version pinning requires
@truv/bridge 2.3.0 or later, or @truv/react 2.4.0 or later.@truv/bridge and @truv/react load the latest Bridge script as soon as you import them. To pin a version, import from @truv/bridge/lazy or @truv/react/lazy instead. Then pass source: 'cdn' with version and integrity from the manifest to load():
init() and the React components wait until you call load(). Call it as early as possible, for example on app start. Only the first load() call takes effect. See the package documentation on npm for the React example and the full API.
Use your own script tag
Withsource: 'cdn', the package inserts the Bridge script into the page at runtime. If your Content Security Policy or another restriction blocks dynamically inserted scripts, add the script tag to your HTML yourself. Then pass source: 'window' to load(). The package uses window.TruvBridge from your script tag and never loads the script itself:
async before your app’s script. window.TruvBridge must exist when you call init() or when a React component opens Bridge. Otherwise, Bridge doesn’t open and logs an error to the browser console.
Update a pinned version
Update to a newer version within 6 months of the pinned version’sreleasedAt date. The period starts at release, not when you pin the version.
1
Get the latest version
Fetch
https://cdn.truv.com/bridge/latest.json.2
Update your code
Replace
src and integrity in the script tag, or version and integrity in the load() call. With source: 'window', update only the script tag.3
Test in sandbox
Create a bridge token on your backend with your sandbox API keys. Open Bridge with that token before you deploy to production.
Pinning locks the version of the Bridge script running on your page. The verification flow that Bridge opens is served by Truv and always runs the latest version.