Web3 React Guide: Unstoppable Login
This is the basic installation guide for the web3-react framework and is best used for React-based single page applications (SPAs). For more information about the UAuth middleware package for web3-react, see the reference and source code on github.
warning
This guide is for @uauth/web3-react
version 2.4.1-rc.0
and later, which uses the latest v8 beta branch of web3-react
.
Step 1: Install the Libraries
Install web3-react
and the connectors for MetaMask, WalletConnect, and UAuth with yarn
or npm
.
yarn add @web3-react/core@beta @web3-react/metamask@beta @web3-react/walletconnect@beta @walletconnect/ethereum-provider @uauth/web3-react@2.4.1-rc.0
npm install --save @web3-react/core@beta @web3-react/metamask@beta @web3-react/walletconnect@beta @walletconnect/ethereum-provider @uauth/web3-react@2.4.1-rc.0
Step 2: Configure the web3-react
Library
Next, configure the MetaMask, WalletConnect, and UAuth connectors for web3-react
.
info
Because popups are a more integration friendly approach, the @uauth/web3-react
library now uses them by default. If you want the "old" redirect functionality, you need to set shouldLoginWithRedirect: true
in your UAuthConnectorConstructorArgs
and create a callback page.
Step 3: Unstoppable Login
Once the connector is configured, you can call the activate()
method to trigger UAuth login. The example App
component below creates a button to acivate and deactive the connector and displays a simple connection and error state.
Congratulations!
You have implemented Unstoppable Login with web3-react.