use-chain-status
v1.0.5
Published
Tiny (<5KB) real-time chain health & gas status hook and utility for EVM networks.
Maintainers
Readme
use-chain-status
use-chain-status provides a tiny, zero-dependency utility + React
hook
to monitor:
- 🟢 Chain health (healthy / slow / degraded / offline)
- ⛽ Base fee
- 💵 Gas price (optional)
- ⚡ Congestion level
- ⏱ Block time delay
- 🔢 Latest block number
- 📈 Pending transactions (if supported)
Perfect for dashboards, wallets, block explorers, DApps, and monitoring UIs.
🚀 Install
npm install use-chain-status📦 Usage (React)
import { useChainStatus } from 'use-chain-status';
export default function App() {
const { status, loading } = useChainStatus(1);
if (loading) return <div>Loading...</div>;
return (
<div>
<p>Health: {status.health}</p>
<p>Block: {status.blockNumber.toString()}</p>
<p>Base Fee: {String(status.baseFee)}</p>
<p>Congestion: {status.congestion}</p>
</div>
);
}🔧 Options
useChainStatus(chainId, {
rpcUrl?: string;
interval?: number; // ms
});Custom RPC
useChainStatus(137, {
rpcUrl: 'https://polygon.llamarpc.com',
interval: 4000,
});🧩 Framework-Agnostic Core
import { getChainStatus } from 'use-chain-status';
const status = await getChainStatus(1, 'https://rpc.ankr.com/eth');📊 What's calculated?
Congestion
Based on gasUsed / gasLimit.
Health Levels
No new block in >12s →
offline6s →
degradedExtreme congestion →
slowOtherwise →
healthy
📦 GitHub Repository
You can find the full source code, issues, discussions, and documentation here:
👉 https://github.com/felaur/use-chain-status
🪪 License
MIT
