@useragent-kit/productkit
v0.3.11
Published
Minimal product-facing window.host contract and helpers for apps running inside a Triangle User Agent
Maintainers
Readme
@useragent-kit/productkit
Minimal app-facing product contract and helpers for apps that choose to mount a
ProductKit-compatible window.host surface.
Install
npm install @useragent-kit/productkitUse this package when you want a narrow, product-oriented runtime surface:
getAddress()storage.get/set/removestatements.subscribe/write/statuson("statement")/off("statement")
Adapters such as @useragent-kit/productkit-adapter-scale are bundled by the
product and mount real host implementations onto this contract.
Positioning
@useragent-kit/productkit is the supported narrow compatibility layer for
product code that wants a small ProductKit-compatible window.host surface.
- use
@useragent-kit/productkitwhen you only need address, storage, and statements, or when you need compatibility with an existing ProductKit host - use
@useragent-kit/product-sdkfor the normal high-level product path in this repo's ecosystem - use TrUAPI through
@useragent-kit/sdk/truapiif you need the canonical full host-product contract or want to build a custom facade/transport layer
ProductKit is not deprecated, but it intentionally stays smaller than the full TrUAPI surface. Hosts do not inject ProductKit by default; products that want this compatibility surface should bundle ProductKit or a ProductKit adapter.
Minimal example
import { hasCoreProductKit } from "@useragent-kit/productkit";
if (!hasCoreProductKit(window.host)) {
throw new Error("ProductKit surface unavailable");
}
const address = await window.host.getAddress();
await window.host.storage.set("last-address", address);
window.host.on("statement", (event) => {
console.log(event);
});Compatibility
- product-side package
- expects a canonical host bridge such as
window.__HOST_API_PORT__, or an existing ProductKit-compatible host surface
Documentation
- Web product guide: https://github.com/paritytech/useragent-kit/blob/main/site/src/content/docs/getting-started/web-product.md
- Positioning: https://github.com/paritytech/useragent-kit/blob/main/site/src/content/docs/ecosystem/productkit-vs-truapi.md
- Migration guide: https://github.com/paritytech/useragent-kit/blob/main/site/src/content/docs/ecosystem/productkit-migration.md
- Quickstart: https://github.com/paritytech/useragent-kit/blob/main/site/src/content/docs/getting-started/index.md
