OpenViSTAI · Agents · Blockchain · Crypto
Menu
Developer Tools

useMetamask

useMetamask is a JavaScript React Hook library for connecting MetaMask to Ethereum dApps and exposing wallet and network state to React components.

Independent OpenViST project profile, based on linked sources.

useMetamask — OpenViST project profile in Developer Tools.
OpenViST project illustration. See the linked sources for product details.
Understand the project

Practical overview

When it fits

Use it when a React Ethereum dApp needs a shared MetaMask connection and state interface across components.

Who it is for

React developers building Ethereum dApps that need MetaMask connection and wallet-state handling.

Documented uses

  • Connect a React app to MetaMask through a reusable hook.
  • Read connected accounts, current chain details, extension availability and connection status.
  • Check existing account access or retrieve chain information without initiating a connection.
Before you choose

Requirements & limits

The repository is public and identifies the project as MIT-licensed. The README documents npm and Yarn installation options.

  • The library is specifically a React Hook for MetaMask, rather than a standalone wallet or full dApp.
  • The app supplies a Web3 interface when calling connect; the README examples mention Web3 and ethers.
  • The exposed state includes accounts, chain ID and name, extension availability, connection status and the provided Web3 instance.

Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.

Source-based practical guide

Add the hook and provider to a React app

Install useMetamask, build it locally if needed, and connect a React app to MetaMask through the documented provider and hook.

Before you start

  • A React application.
  • For a local build, npm greater than 12.13.0; Yarn is optional.
  • MetaMask in the user's browser for the extension-availability and wallet-connection parts of the example.
  • A Web3 interface to pass to connect; the README examples mention Web3 and ethers.

Steps

  1. Install the package with npm i use-metamask or yarn add use-metamask. Alternatively, clone the repository, install dependencies with npm install or yarn, run npm run build or yarn build, and prepare the package with npm pack.

  2. Wrap the app in MetamaskStateProvider.

  3. Import useMetamask in a component and call connect with the chosen Web3 interface.

  4. Read account, chain, availability, connection and Web3 interface information from metaState; use getAccounts to check existing access or getChain to retrieve chain details without calling connect.

Expected outcome

A React component can use the hook's MetaMask connection and state interface to display account and chain information.

Guide limitations

  • The README describes account and chain state handling; it does not document a complete dApp or transaction workflow.
  • The example requires the app to provide a Web3 interface to connect.
Evidence and transparency

Sources & review

Source record details
Source availability
Active
Sources checked
16 October 2026
Original website title
mdtanrikulu/use-metamask · Official homepage title · retained in its source language