Practical overview
When it fits
Use it when a React dApp needs declarative Ethereum reads with cached state and background refresh, or needs contract data organized around component hooks.
Who it is for
- Developers building React-based Ethereum dApps.
- Teams that need to keep on-chain or contract values available in component state.
Documented uses
- Read Ethereum methods such as account balances or block numbers from React components.
- Fetch smart-contract values such as ERC-20 balances using a contract address, method and arguments.
- Group multiple contract reads and reduce duplicate requests within a rendered component tree.
- Refresh cached values and respond to contract events, with callback-based optimistic updates.
Requirements & limits
- Contract interactions require the ABI associated with the contract.
- The README describes stale-while-revalidate behavior: cached data is returned before an on-chain fetch supplies an updated value.
- The example configures a Web3 provider and ABI mappings through EthSWRConfig; its broader setup uses Web3React and ethers-related packages.
Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.
Install Ether-SWR in a project
Add the Ether-SWR package as a dependency.
Before you start
- A project using Yarn or npm.
Steps
Install with
yarn add ether-swror the command below.npm install --save ether-swrContinue to the README’s Getting Started section for the documented configuration and usage example.
Expected outcome
Ether-SWR is added as a project dependency.
Guide limitations
- Installation alone does not configure a provider or demonstrate a running application.
Configure Ether-SWR for Ethereum balance data
Set up the documented global fetcher and request ETH and ERC-20 balances in a React app.
Before you start
- Ether-SWR installed in the project.
- A Web3Provider and Web3React setup, an injected connector, and an ERC-20 ABI file, as shown in the README example.
Steps
Import
useEtherSWRandEthSWRConfig, along with the provider, wallet, and formatting utilities used by the example.Map the ERC-20 contract address to its ABI in the
ABIsconfiguration.Inside the connected-wallet branch, wrap the balance components in
EthSWRConfigwithweb3Provider: library, the ABI map, andrefreshInterval: 30000.Use
useEtherSWR(['getBalance', account, 'latest'])for the ETH balance anduseEtherSWR([address, 'balanceOf', account])for a token balance.
Expected outcome
The example configures a global fetcher and requests ETH and token balances; mounted keys are set to refresh every 30 seconds.
Guide limitations
- This describes the README example, not a verified build or execution.
- Contract calls require the associated ABI to be provided; the example uses a specific DAI contract address.
Sources & review
Source record details
- Source availability
- Active
- Sources checked
- 15 October 2026
- Original website title
- aboutlo/ether-swr · Official homepage title · retained in its source language

