To integrate Portal, an organization adds a client library to their web app, configures a
CNAME record, and adds a few server API endpoints.
Basic setup
The basic Portal setup consists of a single packages:@portal-hq/web- The core Portal library
Portal in your app. We recommend only initializing one Portal instance per user.
Authentication
Follow this guide to gather all of the credentials you need to Authenticate to Portal.Installation
- yarn
- npm
Update TSConfig
The Web SDK uses the TSConfiglib configuration to properly type interaction with the DOM. Update your TSConfig file to include this:
Initializing Portal
WhenrpcConfig is omitted, the SDK automatically generates gateway URLs for 13 built-in chains. The gateway host defaults to web.portalhq.io, and derives from host (or gatewayHost) when you set a custom subdomain. No third-party RPC provider setup is required.
buildDefaultRpcConfig to start from the default set and extend it:
The 13 built-in chains covered by the default gateway config are: Ethereum (
eip155:1), Sepolia (eip155:11155111), Polygon (eip155:137), Polygon Amoy (eip155:80002), Base (eip155:8453), Base Sepolia (eip155:84532), Monad (eip155:143), Monad Testnet (eip155:10143), Optimism (eip155:10), Arbitrum One (eip155:42161), Avalanche C-Chain (eip155:43114), Solana Mainnet (solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp), and Solana Devnet (solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1). Polygon Mumbai (eip155:80001) has been removed — use Polygon Amoy (eip155:80002) instead.logLevel parameter. For full logging configuration, including custom loggers and runtime level changes, see Logging Configuration.
If you are using Client Session Tokens (CSTs), this hint is for you.When your user’s CST expires, all Portal SDKs will throw an error on the next MPC Operation the user makes (e.g. creating a wallet, backing up a wallet, recovering a wallet, or signing). That error will include a code
SESSION_EXPIRED in the SDK methods, which you can use as an indicator to refresh your CST.