Skip to main content

Custom Web3-React connector

web3-react connectos

With custom connector you can use web3-react library or useWeb3 hook without 3rd party connectors like Metamask, WalletConnect etc.

const getLibrary = (
provider: provider,
connector?: AbstractConnector | IInAppWalletConnector
) => {
if (connector) {
const appConnector = connector as IInAppWalletConnector
if (appConnector.name === Connectors.InAppWallet) {
const web3 = appConnector.web3
return web3
}
}
return new Web3(provider)
}

export const Web3Provider: React.FC = () => {
return (
<Web3ReactProvider getLibrary={getLibrary}>
<Web3ProviderUpdater />
</Web3ReactProvider>
)
}