Host SDK
For Remote DOM UI Extensions. @gowarehouse/ui-extensions provides a Host API accessor; it does not polyfill unsupported deployment features or grant additional permissions.
Access the API
Obtain the API inside your extension's render entry. Do not call it from a regular website or App Home:
import { getExtensionAPI } from '@gowarehouse/ui-extensions';
export default function render() {
const api = getExtensionAPI();
const title = api.i18n.translate('name');
// Use title to create UI components supported by the Host.
}The accessor throws gowarehouse_host_required without a Host, or host_i18n_v1_required without i18n. The /testing export is for App tests, not for creating a substitute Host in production.
SDK 0.1.0 type coverage
| Member | Usage |
|---|---|
data.selected | Initial [{ id }] snapshot; interpret the resource type according to the target |
locale | The Host user's locale |
i18n.translate(key, replacements?) | Read translations from the release; all locales must have the same keys |
i18n.formatNumber(value, options?) | Format numbers for the locale |
i18n.formatDate(value, options?) | Accepts a Date or epoch milliseconds; pass timeZone when a fixed timezone is needed |
request(input) | Restricted requests for the Admin order action; see metadata |
refresh() | Ask the Host to reload page data; returns a Promise |
close() | Close the action; returns a Promise and belongs at the end of the operation |
SDK 0.1.0 types still accept only PATCH /orders/${string}/metadata with { flag: true }, and declare only metadata.flag in successful results. The Host supports a broader metadata contract. Do not treat the package's types as the full Host schema or hide the difference with as any.
Additional Host fields
The current Host runtime also provides sessionToken.get(), app.url, and warehouse_id, plus data.order_id for fulfillment targets. These are not yet declared in SDK 0.1.0's ExtensionAPI. Check the destination deployment and your SDK contract before relying on them. See Identity and authorization for backend use.
request() is available only for the specified Admin target. Do not reuse an action's API object for another installation or instance.
Promises and operation order
An s-button click event provides respondWith(promise) to pass the whole operation to the Host. Handle both { success: false, message } and Promise rejection: network interruptions, invalid inputs, and instance termination do not always produce a normal result object.
After a successful write, await api.refresh(), then await api.close() if needed. A refresh or close failure does not prove that the write failed; do not automatically resend a write that may already have succeeded.
See Your first App for a complete example and Troubleshooting for error handling.