ChainRouter
TypeScript client for ChainRouter (opens in a new tab) — Web5 Nexus managed multi-chain EVM JSON-RPC with health-aware routing.
SDK_Files: chainrouter-sdk/ · npm @web5nexus/chainrouter (opens in a new tab)
Use it to resolve RPC URLs, call eth_* methods, list activated chains, and build wallet_addEthereumChain params — without hardcoding public endpoints.
Install
npm install @web5nexus/chainrouterGet an API key
- Open https://chainrouter.web5.nexus (opens in a new tab)
- Create a project and copy the key (
cr_…) - For browser apps, add your origin under Browser origins (CORS)
When ChainRouter is used as an embedded-wallet rpcTarget (Web3Auth / Auth Modal), vendor iframe origins are allowlisted for valid keys.
Quick start
import { ChainRouter } from '@web5nexus/chainrouter'
const cr = new ChainRouter({
apiKey: process.env.CHAINROUTER_API_KEY!,
})
const url = await cr.resolveRpcUrl(1) // Ethereum
const block = await cr.request(1, 'eth_blockNumber', [])With Auth Modal
transport={{
mode: 'chainrouter',
apiKey: process.env.NEXT_PUBLIC_CHAINROUTER_API_KEY!,
chainId: 1,
}}See Auth Modal for full Connect Modal setup.
Related
- Auth Modal
- Web5js — multi-chain data / RPC product APIs
- Bitcoin Core