tryora-embed-core
v0.1.2
Published
Shared Tryora embed URL builders and script lifecycle hooks.
Readme
tryora-embed-core
Shared helpers for Tryora embed integration.
Install
yarn add tryora-embed-core
# or
npm i tryora-embed-coreExports
TRYORA_STORE_IDTRYORA_BACKEND_ORIGINTRYORA_EMBED_SCRIPT_PATHTRYORA_CANVAS_URL_PREFIXTRYORA_CATALOG_EMBED_SRCTRYORA_STYLER_PAGE_VIEW_EMBED_SRCgetTryoraConfig()configureTryoraEmbed({ storeId, backendOrigin })buildCatalogEmbedSrc()buildStylerPageViewEmbedSrc()getTryoraCanvasUrlPrefix()getTryoraEmbedScriptBaseUrl()buildProductDetailEmbedSrc(productSku)buildProductGalleryEmbedSrc(productSku)useTryoraBodyScript(src)
Configuration
You can configure at runtime (recommended):
import { configureTryoraEmbed } from 'tryora-embed-core';
configureTryoraEmbed({
storeId: 'YOUR_STORE_ID',
backendOrigin: 'https://your-tryora-host.example'
});Or set globals before app bootstrap:
globalThis.__TRYORA_EMBED_CONFIG__ = {
storeId: 'YOUR_STORE_ID',
backendOrigin: 'https://your-tryora-host.example'
};Or pass env variables at build/runtime:
TRYORA_STORE_IDTRYORA_BACKEND_ORIGIN
Usage
import {
buildCatalogEmbedSrc,
buildProductDetailEmbedSrc,
configureTryoraEmbed,
useTryoraBodyScript
} from 'tryora-embed-core';
configureTryoraEmbed({
storeId: 'YOUR_STORE_ID',
backendOrigin: 'https://your-tryora-host.example'
});Catalog page
function CatalogTryoraEmbed() {
useTryoraBodyScript(buildCatalogEmbedSrc());
return null;
}Product detail page
function ProductDetailTryoraEmbed({ sku }) {
useTryoraBodyScript(buildProductDetailEmbedSrc(sku));
return null;
}Important notes
- For catalog VTO mode, product markup must include
data-vto-product-idwith a SKU or vendor id. - This package contains shared logic only. Framework-specific wiring (for example Venia intercepts) stays in each application.
