Skip to main content

Product hydration

Product hydration allows your app to supply enriched product data (pricing, images, variants, stock) to the Bambuser live player at runtime. When a live show starts, the player fires a provide-product-data event listing all products it needs data for. Your app looks up each product by SKU and pushes the data back into the player using invoke('updateProductWithData', ...).

Prerequisites

currency and locale must be set in your player configuration. Product hydration will not work without them.

<BambuserVideoView
ref={playerRef}
id="your-show-id"
configuration={{
currency: 'USD', // Required for product hydration
locale: 'en-US', // Required for product hydration
}}
onEvent={handleEvent}
/>

Handle the provide-product-data Event

The player fires provide-product-data at show start, and again whenever a new product needs to be displayed. Handle it in your onEvent callback.

import { Platform } from 'react-native';

function handleEvent(e) {
const { type, data } = e.nativeEvent;

if (type === 'provide-product-data') {
const products = Platform.OS === 'ios'
? data?.event?.products
: data?.products;

hydrate(products ?? []);
}
}

Each entry in the products array has:

FieldTypeDescription
idstringBambuser-generated product ID. Pass this back to the player.
refstringYour product SKU. Use this to look up your own data.
urlstringProduct URL as set in the Bambuser dashboard.

Send Product Data Back to the Player

Call invoke('updateProductWithData', ...) for each product. The arguments string must start with the Bambuser product id in single quotes, followed by a comma and the product object:

async function hydrate(products) {
for (const product of products) {
const id = product.id;
const sku = product.ref;
if (!id || !sku) continue;

const source = await YourProductService.product(sku);
if (!source) continue;

const hydrationJson = `{
sku: '${source.sku}',
name: '${source.name}',
brandName: '${source.brand}',
introduction: '${source.shortDescription}',
description: '${source.description}',
variations: [
{
sku: '${source.variationSku}',
name: '${source.variationName}',
colorName: '${source.colorName}',
imageUrls: ['${source.imageUrl}'],
sizes: [
{
sku: '${source.sizeSku}',
currency: 'USD',
current: ${source.price},
original: ${source.originalPrice},
name: '${source.sizeName}',
inStock: ${source.stock},
}
]
}
]
}`;

await playerRef.current?.invoke(
'updateProductWithData',
`'${id}', ${hydrationJson}`,
);
}
}

Full Product Data Structure

The product object passed to updateProductWithData supports the following fields:

Product

FieldTypeRequiredDescription
skustringYesYour product SKU / identifier.
namestringYesProduct display name.
brandNamestringYesBrand name.
introductionstringNoShort introductory text.
descriptionstringNoFull description, supports HTML.
variationsarrayYesList of product variations (colors/styles).

Variation

FieldTypeRequiredDescription
skustringYesVariation SKU.
namestringYesVariation display name.
colorNamestringYesColor name shown in the variation selector.
colorHexCodestringNoHex color code, e.g. "#000000".
imageUrlsstring[]YesOrdered list of image URLs for this variation.
sizesarrayYesList of sizes/SKUs for this variation.

Size

FieldTypeRequiredDescription
skustringYesSize-level SKU.
namestringYesSize name, e.g. "Small", "XL".
currentnumberYesCurrent (sale) price.
originalnumberNoOriginal price, shown as strike-through.
currencystringYesThree-letter currency code, e.g. "USD".
inStocknumberYesAvailable stock quantity (0 = out of stock).
perUnitnumberNoPrice per unit (for bundle/multi-pack pricing).
unitAmountnumberNoQuantity per unit.
unitDisplayNamestringNoUnit label, e.g. "kg", "L", "st".

Notes

  • The player may fire provide-product-data multiple times during a show as new products are highlighted. Your hydration handler must be idempotent.
  • Fields not provided in your hydration response fall back to data previously scraped or manually set in the Bambuser dashboard.
  • invoke is asynchronous and returns a Promise; await it when you need to chain further work or surface errors.
  • If you prefer a typed builder over raw string interpolation, you can construct the hydration object in JS and JSON.stringify it, then pass `'${id}', ${json}` as the arguments string.