Getting started

Load the SDK, initialize the bridge, read your launch context, and close.

Admin App Bridge is a single browser script with no build step and no dependencies. Load the version-pinned URL in production so a future major cannot move under your app; the unpinned alias tracks the latest major and is for demos only.

index.html html
<!-- Production: pin the major. -->
<script src="https://storage.tringify.com/app-bridge@1.js"></script>

TringifyBridge.init(options?)#

The script attaches a TringifyBridge global (and exports via CommonJS if bundled). init() returns the shared bridge instance, creating it on first call — it is a singleton, so a second init() returns the same instance and ignores its options. TringifyBridge.major and TringifyBridge.version report the loaded contract.

Option

Type

Default

Meaning

apiBase

string

https://api-store.tringify.com

Store API base — override only for non-production environments.

app.js javascript
const bridge = TringifyBridge.init();
await bridge.ready();

bridge.ready()#

Resolves once Tringify Storeadmin has acknowledged the iframe. It resolves with the same launch context getContext() returns. Await it before using host UI. Also emitted as the ready event via bridge.on("ready", …).

javascript
const ctx = await bridge.ready();  // → the launch context

bridge.getContext()#

Returns the full launch context, owned by the host and kept off the launch URL so no PII leaks into the link. Resolves an object:

Field

Meaning

store_id

The store being managed.

app_id

Your installed app.

host

The host surface — storeadmin.

store_name

The store's display name.

primary_domain

The store's primary domain.

timezone

The store's IANA timezone (e.g. Asia/Kolkata).

currency

The store's currency code.

locale

The admin's active UI language (the merchant's profile language).

scopes

The scopes granted to your app on this store.

theme

The host theme — light or dark. Changes push a theme:change event.

expires_at

When the current bridge session expires (ISO 8601).

javascript
const ctx = await bridge.getContext();
bridge.toast("Connected to " + ctx.store_name, "success");

bridge.launch#

The raw handshake values, available synchronously (no round trip) before ready() resolves — a plain object, not a function: { storeId, appId, host, token }. token is the signed launch (bridge) token; treat it as a launch credential, not a long-lived key. Prefer getContext() for everything except the earliest bootstrap.

bridge.close()#

Closes the embedded surface and returns the merchant to the installed-apps list.

The launch handshake#

When a merchant opens your app, Tringify Storeadmin mints a short-lived bridge session and loads your admin_ui_url in a sandboxed iframe. The URL carries tringify_bridge_token (signed, valid ten minutes), tringify_store_id, tringify_app_id, and tringify_host. On init the SDK captures the token and scrubs it from the address bar so it does not linger in history or referrer logs. The host validates the iframe origin against your app's registered origins on every message, and the SDK pins the host origin on first contact — a mismatched origin is ignored on both sides.