Host¶
Introduction¶
@parity/product-sdk-host detects the Polkadot Host container and exposes its full surface directly: accounts and signing, storage, permissions, payments, chat, notifications, navigation, entropy, the statement store, and chain providers. It is the foundation the other SDK packages build on, wrapping the Host protocol so higher-level packages can offer focused APIs.
Most Products reach these capabilities through the higher-level packages rather than calling the Host directly. Use this package when you need a surface those packages do not wrap yet, or when you need to detect whether your Product is running inside a Host at all.
When to Use It¶
- To detect whether your Product is running inside a Host container (
isInsideContainer,isInsideContainerSync) and branch behavior accordingly. - To reach a Host capability directly: accounts and signers, payments, chat, push notifications, deep-link navigation, or feature and chain probes.
- To get a PAPI-compatible provider that routes chain traffic through the Host (
getHostProvider), or the native statement store transport (getStatementStore). - Prefer the higher-level packages where they exist: Signer for signing, Local Storage for key-value storage, and Chain Client for connections. Outside a container, every getter resolves to
null.
Core Concepts¶
- Container detection:
isInsideContainer()is the async check;isInsideContainerSync()is a fast heuristic. Every Host getter returnsnullwhen not inside a container. - Feature-detection getters:
getAccountsProvider,getHostLocalStorage,getPaymentManager,getChatManager,getNotificationManager, and more each return an adapter, ornullif the Host is absent. - Two error conventions: Flat operations such as
requestPermissionandnavigateToreturn aResult(check.ok). Adapter methods keep throwing, because they implement external interfaces such as PAPI's provider that cannot carry aResult. - Accounts surface:
getAccountsProvider()exposes product accounts (app-scoped keypairs the Host derives per Product) and legacy accounts (the user's existing wallet keys), plus signer factories for each. - Chain support probes:
getHostProvider(genesisHash)throws aChainNotSupportedErrorwhen the Host cannot serve a chain, rather than returning a provider that hangs.
Detect the Container and Read Host Storage¶
Check for a Host, then use its storage surface directly:
import {
isInsideContainer,
getHostLocalStorage,
} from '@parity/product-sdk-host';
if (await isInsideContainer()) {
const storage = await getHostLocalStorage();
if (storage) {
await storage.writeString('theme', 'dark');
const theme = await storage.readString('theme'); // "" if missing
}
}
Get a Product Account and Signer¶
Reach an app-scoped product account and build a signer for it:
import { getAccountsProvider } from '@parity/product-sdk-host';
const accounts = await getAccountsProvider();
if (accounts) {
const account = await accounts
.getProductAccount('my-product.dot', 0)
.match((a) => a, () => null);
if (account) {
const signer = accounts.getProductAccountSigner(account);
}
}
Limitations¶
- Every getter returns
nulloutside a Host container; this package has no standalone fallback. - The package mixes two error conventions: flat operations return a
Result, while adapter methods throw. Handle both. getHostProviderthrowsChainNotSupportedErrorwhen the Host cannot serve a chain, rather than returning a working provider.- Host storage returns an empty string for a missing key; normalize it yourself, or use the Local Storage package, which does.
Where to Go Next¶
-
Learn App Development Reference
How the Host mediates between your Product and Polkadot's infrastructure.
-
Learn Signer
The higher-level way to discover accounts and sign, built on this package.
-
External API Reference
The complete
hostsurface: container detection and every Host capability getter.
| Created: September 2, 2026