@web5nexus/chainrouter
v0.1.0
Published
Client SDK for ChainRouter — managed EVM RPC via chainId + API key, or custom upstreams
Readme
@web5nexus/chainrouter
Client SDK for ChainRouter — OpenRouter-style managed EVM RPC with Chainlist health checks and failover.
Install
npm install @web5nexus/chainrouterGet a free API key
- Sign up at https://chainrouter.web5.nexus
- Create a project → copy the API key (
cr_…) - For browser dApps, add your origin under Browser origins (CORS)
Usage
import { ChainRouter } from '@web5nexus/chainrouter'
const cr = new ChainRouter({
apiKey: process.env.CHAINROUTER_API_KEY!,
})
// MetaMask / ethers RPC URL
const url = cr.rpcUrl(1) // https://chainrouter.web5.nexus/1/cr_…
// List admin-activated chains
const chains = await cr.listChains()
// JSON-RPC
const blockNumber = await cr.request(1, 'eth_blockNumber')
// wallet_addEthereumChain helper
const addParams = await cr.walletAddEthereumChainParams(8453)Custom RPC instead
If you prefer your own upstream, pass rpcUrl + chainId to @web5nexus/sociallogin EvmRpc in custom mode (see docs). ChainRouter is optional.
License
MIT
