react-use-web3
React hook for using the Web3 object in your DApps.
🦊 Web3 Documentation
Install:
npm i react-use-web3
peerDependencies
Ensure you have the correct "peerDependencies":
Set an httpProvider url:
Use the default Web3 provider (Usually MetaMask):
const web3 network = ;
Or, pass an httpProvider URL to the hook:
const web3 network = ;
React.Context
Simple Example: Use with ;; const Web3Context = ; { const web3 network = ; return <Web3ContextProvider value= web3 network > children </Web3ContextProvider> ;};