{"_id":"@d13co/algo-metrics-react","_rev":"4-1ca49ba72b126294d375488e4efcaf7d","name":"@d13co/algo-metrics-react","dist-tags":{"latest":"1.2.1"},"versions":{"1.0.0":{"name":"@d13co/algo-metrics-react","version":"1.0.0","license":"MIT","_id":"@d13co/algo-metrics-react@1.0.0","maintainers":[{"name":"bitd13co","email":"bit@d13.co"}],"homepage":"https://github.com/d13co/algo-metrics-sdk/tree/main/packages/react#readme","bugs":{"url":"https://github.com/d13co/algo-metrics-sdk/issues"},"dist":{"shasum":"3cc3b48819ae6bb5601a6baca5efe28489c5b2d4","tarball":"https://registry.npmjs.org/@d13co/algo-metrics-react/-/algo-metrics-react-1.0.0.tgz","fileCount":30,"integrity":"sha512-ujkAs6w3pE4l1CLcJJxJ0aRV87VtHiyUxUFdhaBgvcUGFHN6nem3ixiNXO8TxxYwsYhahGK8u4A/GKuXcOxL0g==","signatures":[{"sig":"MEQCIEuPwu1ZVRPVb80zQdWjOHPJIjA/aaxfYSL4EVqrPcXSAiBju/mII9uoNE/7NRfoJSLMeri5oX5Aosaz6KKsc+3MSw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":41930},"main":"dist/index.js","type":"module","_from":"file:d13co-algo-metrics-react-1.0.0.tgz","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"scripts":{"build":"tsc"},"_npmUser":{"name":"bitd13co","email":"bit@d13.co"},"_resolved":"/tmp/3ea14af00ac575a2314a19bc338a400d/d13co-algo-metrics-react-1.0.0.tgz","_integrity":"sha512-ujkAs6w3pE4l1CLcJJxJ0aRV87VtHiyUxUFdhaBgvcUGFHN6nem3ixiNXO8TxxYwsYhahGK8u4A/GKuXcOxL0g==","repository":{"url":"git+ssh://git@github.com/d13co/algo-metrics-sdk.git","type":"git","directory":"packages/react"},"_npmVersion":"10.9.3","description":"React hooks for @d13co/algo-metrics-sdk","directories":{},"_nodeVersion":"22.19.0","dependencies":{"@d13co/algo-metrics-sdk":"1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"peerDependencies":{"react":"^18.0.0 || ^19.0.0"},"_npmOperationalInternal":{"tmp":"tmp/algo-metrics-react_1.0.0_1773451822093_0.4308970552156315","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@d13co/algo-metrics-react","version":"1.1.0","license":"MIT","_id":"@d13co/algo-metrics-react@1.1.0","maintainers":[{"name":"bitd13co","email":"bit@d13.co"}],"homepage":"https://github.com/d13co/algo-metrics-sdk/tree/main/packages/react#readme","bugs":{"url":"https://github.com/d13co/algo-metrics-sdk/issues"},"dist":{"shasum":"c51b21a5e5c5cf0eeb028649316fc250c5311f04","tarball":"https://registry.npmjs.org/@d13co/algo-metrics-react/-/algo-metrics-react-1.1.0.tgz","fileCount":30,"integrity":"sha512-cIi+uUaKbjcwRFDECSS+df9enfHwOsDgrHgSh9vE9l7dX/rRzRjT7xe4yGuAo7MMryDr1I1sTX2h4ZlIDjreRA==","signatures":[{"sig":"MEUCIEuCI0KIeakX8ME7IA5TnqBHTgE/TUqHY9YWhH9LknMAAiEAkgT/Uv2lh/JMjJkuwovsNCEDX7rSY7+pm6zG7Lwq8n8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":41427},"main":"dist/index.js","type":"module","_from":"file:d13co-algo-metrics-react-1.1.0.tgz","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"scripts":{"build":"tsc"},"_npmUser":{"name":"bitd13co","email":"bit@d13.co"},"_resolved":"/tmp/3d7e3c40bf6843010a5e88e5043b1081/d13co-algo-metrics-react-1.1.0.tgz","_integrity":"sha512-cIi+uUaKbjcwRFDECSS+df9enfHwOsDgrHgSh9vE9l7dX/rRzRjT7xe4yGuAo7MMryDr1I1sTX2h4ZlIDjreRA==","repository":{"url":"git+ssh://git@github.com/d13co/algo-metrics-sdk.git","type":"git","directory":"packages/react"},"_npmVersion":"10.9.3","description":"React hooks for @d13co/algo-metrics-sdk","directories":{},"_nodeVersion":"22.19.0","dependencies":{"@d13co/algo-metrics-sdk":"1.1.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"peerDependencies":{"react":"^18.0.0 || ^19.0.0"},"_npmOperationalInternal":{"tmp":"tmp/algo-metrics-react_1.1.0_1773453773607_0.9749732039396268","host":"s3://npm-registry-packages-npm-production"}},"1.2.0":{"name":"@d13co/algo-metrics-react","version":"1.2.0","license":"MIT","_id":"@d13co/algo-metrics-react@1.2.0","maintainers":[{"name":"bitd13co","email":"bit@d13.co"}],"homepage":"https://github.com/d13co/algo-metrics-sdk/tree/main/packages/react#readme","bugs":{"url":"https://github.com/d13co/algo-metrics-sdk/issues"},"dist":{"shasum":"1f069196413ea1db6b022cc0671e09ba36b1e102","tarball":"https://registry.npmjs.org/@d13co/algo-metrics-react/-/algo-metrics-react-1.2.0.tgz","fileCount":30,"integrity":"sha512-vRj9fQcHjsiV3yjk729tCMo84tmKbXjDCsFE8a27LCqoXktR66SlExXWrixnz7ouKLLK95dYbmpwO5IThhPF1g==","signatures":[{"sig":"MEYCIQDW+IYLakPc2l7KNGMr/qZI6s8r3bzC63DBLcK7P5mBZwIhAPgMKsOr6B+mnBkeOdecAF2yXATb87UeiS/nggevd01D","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":43521},"main":"dist/index.js","type":"module","_from":"file:d13co-algo-metrics-react-1.2.0.tgz","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"scripts":{"build":"tsc"},"_npmUser":{"name":"bitd13co","email":"bit@d13.co"},"_resolved":"/tmp/7d7c2e8c206873675213a76524acf6a9/d13co-algo-metrics-react-1.2.0.tgz","_integrity":"sha512-vRj9fQcHjsiV3yjk729tCMo84tmKbXjDCsFE8a27LCqoXktR66SlExXWrixnz7ouKLLK95dYbmpwO5IThhPF1g==","repository":{"url":"git+ssh://git@github.com/d13co/algo-metrics-sdk.git","type":"git","directory":"packages/react"},"_npmVersion":"10.9.3","description":"React hooks for @d13co/algo-metrics-sdk","directories":{},"_nodeVersion":"22.19.0","dependencies":{"@d13co/algo-metrics-sdk":"1.2.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"peerDependencies":{"react":"^18.0.0 || ^19.0.0"},"_npmOperationalInternal":{"tmp":"tmp/algo-metrics-react_1.2.0_1775047173841_0.48861875488067263","host":"s3://npm-registry-packages-npm-production"}},"1.2.1":{"name":"@d13co/algo-metrics-react","version":"1.2.1","type":"module","description":"React hooks for @d13co/algo-metrics-sdk","main":"dist/index.js","module":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"import":"./dist/index.js","types":"./dist/index.d.ts"}},"publishConfig":{"access":"public"},"license":"MIT","repository":{"type":"git","url":"git+ssh://git@github.com/d13co/algo-metrics-sdk.git","directory":"packages/react"},"bugs":{"url":"https://github.com/d13co/algo-metrics-sdk/issues"},"homepage":"https://github.com/d13co/algo-metrics-sdk/tree/main/packages/react#readme","dependencies":{"@d13co/algo-metrics-sdk":"1.2.1"},"peerDependencies":{"react":"^18.0.0 || ^19.0.0"},"scripts":{"build":"tsc","test":"vitest run --config ../../vitest.config.ts","test:watch":"vitest --config ../../vitest.config.ts"},"_id":"@d13co/algo-metrics-react@1.2.1","_integrity":"sha512-C+Wajr1Z3n/E41V4Af4FPB8m24iGqU4XWk+Uio5qjb2lb/txDGyio4+uXGtENZy+6ecrCmqLKIWcGsX7Cb+xwA==","_resolved":"/tmp/62fee97c28df7be80274687de33f6d35/d13co-algo-metrics-react-1.2.1.tgz","_from":"file:d13co-algo-metrics-react-1.2.1.tgz","_nodeVersion":"22.19.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-C+Wajr1Z3n/E41V4Af4FPB8m24iGqU4XWk+Uio5qjb2lb/txDGyio4+uXGtENZy+6ecrCmqLKIWcGsX7Cb+xwA==","shasum":"e37a56e0f41a9871922f870d744c725383110447","tarball":"https://registry.npmjs.org/@d13co/algo-metrics-react/-/algo-metrics-react-1.2.1.tgz","fileCount":22,"unpackedSize":19052,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDEELXVs/sdpOg7wiDo4uV62xKF8MbOO/P8WsCRL6BFXQIgGASRO7MsKVF0PZzVBDt8Q7arGWHXDdmsHyR8IRqVBkk="}]},"_npmUser":{"name":"bitd13co","email":"bit@d13.co"},"directories":{},"maintainers":[{"name":"bitd13co","email":"bit@d13.co"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/algo-metrics-react_1.2.1_1786848236434_0.9978703432594243"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-14T01:30:21.970Z","modified":"2026-08-16T02:43:56.759Z","1.0.0":"2026-03-14T01:30:22.266Z","1.1.0":"2026-03-14T02:02:53.755Z","1.2.0":"2026-04-01T12:39:34.043Z","1.2.1":"2026-08-16T02:43:56.584Z"},"bugs":{"url":"https://github.com/d13co/algo-metrics-sdk/issues"},"license":"MIT","homepage":"https://github.com/d13co/algo-metrics-sdk/tree/main/packages/react#readme","repository":{"type":"git","url":"git+ssh://git@github.com/d13co/algo-metrics-sdk.git","directory":"packages/react"},"description":"React hooks for @d13co/algo-metrics-sdk","maintainers":[{"name":"bitd13co","email":"bit@d13.co"}],"readme":"# @d13co/algo-metrics-react\n\n[![npm version](https://img.shields.io/npm/v/@d13co/algo-metrics-react)](https://www.npmjs.com/package/@d13co/algo-metrics-react)\n\nReact hooks for [@d13co/algo-metrics-sdk](https://www.npmjs.com/package/@d13co/algo-metrics-sdk). Wraps the SDK with a single shared watcher callback so multiple components can consume live Algorand block metrics without duplicate network calls.\n\n## Installation\n\n```bash\npnpm add @d13co/algo-metrics-react @d13co/algo-metrics-sdk\n```\n\nReact 18 or 19 is required as a peer dependency.\n\n## Quick Start\n\nWrap your app with `AlgoMetricsProvider`, then use hooks anywhere inside:\n\n```tsx\nimport { AlgoMetricsProvider, useLatestRound, useTransactionsPerSecond } from '@d13co/algo-metrics-react';\n\nfunction App() {\n  return (\n    <AlgoMetricsProvider>\n      <Dashboard />\n    </AlgoMetricsProvider>\n  );\n}\n\nfunction Dashboard() {\n  const round = useLatestRound();\n  const tps = useTransactionsPerSecond();\n\n  return (\n    <div>\n      <p>Latest round: {round?.toString() ?? '–'}</p>\n      <p>TPS: {tps?.toFixed(1) ?? '–'}</p>\n    </div>\n  );\n}\n```\n\n## Provider\n\n### `<AlgoMetricsProvider>`\n\n| Prop | Type | Default | Description |\n| --- | --- | --- | --- |\n| `options` | `AlgoMetricsSDKOptions` | `{}` | Options forwarded to `new AlgoMetricsSDK(options)` |\n| `sdk` | `AlgoMetricsSDK` | — | Use an existing SDK instance instead of creating one |\n| `children` | `ReactNode` | — | — |\n\nThe provider registers a single watcher callback on mount and unregisters on unmount. It auto-detects whether the connected network is mainnet by comparing the genesis hash from `algod.getTransactionParams()`. All hooks derive their values from the shared block data via context.\n\n## Hooks\n\n### `useLatestRound(): bigint | null`\n\nReturns the most recent block round number, or `null` while loading.\n\n### `useAverageRoundTime(): number | null`\n\nReturns the average time between blocks in seconds, computed as `(last.ts - first.ts) / (blockCount - 1)`.\n\n### `useTransactionsPerSecond(): number | null`\n\nReturns the current transactions per second, computed as `(last.tc - first.tc) / (last.ts - first.ts)`.\n\n### `useTransactionCount(): bigint | null`\n\nReturns the cumulative transaction count. Adds `563,279` on mainnet to account for the genesis offset.\n\n### `useBlockData(): BlockRoundTimeAndTc[] | null`\n\nReturns the raw block data array from the provider.\n\n### `useAlgoMetricsContext(): AlgoMetricsContextValue`\n\nReturns the full context value: `{ data, isLoading, sdk, isMainnet }`.\n\n## Pure Functions\n\nThe compute functions are also exported for use outside of React:\n\n```ts\nimport { getLatestRound, getAverageRoundTime, getTransactionsPerSecond, getTransactionCount, MAINNET_TC_OFFSET } from '@d13co/algo-metrics-react';\n```\n\n## Custom Algorand Client\n\n```tsx\nimport { AlgorandClient } from '@algorandfoundation/algokit-utils';\n\n<AlgoMetricsProvider options={{ algorand: AlgorandClient.testNet() }}>\n  {children}\n</AlgoMetricsProvider>\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md"}