# Manual installation

Add packages

{% tabs %}
{% tab title="npm" %}
{% code overflow="wrap" %}

```
npm install @web3-react/core@8.0.32-beta.0 @web3-react/walletconnect@8.0.33-beta.0
```

{% endcode %}
{% endtab %}

{% tab title="yarn" %}
{% code overflow="wrap" %}

```
yarn add @web3-react/core@8.0.32-beta.0 @web3-react/walletconnect@8.0.33-beta.0
```

{% endcode %}
{% endtab %}
{% endtabs %}

{% hint style="info" %}
We decided after some research to use beta versions of a web3-react package but stable 8 will be out soon.
{% endhint %}

### Connector setup

<pre class="language-typescript"><code class="lang-typescript">import { initializeConnector } from '@web3-react/core'
import { WalletConnect } from '@web3-react/walletconnect'
<strong>
</strong><strong>export const [metapro, metaproHooks] = initializeConnector&#x3C;WalletConnect>(
</strong>  (actions) =>
    new WalletConnect({
      actions,
      treatModalCloseAsError: true,
      options: {
        bridge: 'https://tst-bridge.metaprotocol.one',
        rpc: { [56]: "https://bsc-dataseed1.ninicoin.io" }
      }
    })
)
</code></pre>

### Provider setup

{% code lineNumbers="true" %}

```typescript
import { Web3ReactHooks, Web3ReactProvider } from '@web3-react/core'
import {WalletConnect} from '@web3-react/walletconnect'
import {metapro, metaproHooks} from 'yourPathToMetapro/connector'

const connectors: [WalletConnect, Web3ReactHooks][] = [[metapro, metaproHooks]]

function App() {
  return (
    <>
      <Web3ReactProvider connectors={connectors}>
         <HomePage />
      </Web3ReactProvider>
    </>
  );
}

export default App;
```

{% endcode %}

{% hint style="warning" %}
A common issue with CRA apps in the newest versions is missing buffer. We need to install it manually and declare it in the main file.

Missing buffer can cause errors on WalletConnect integration.

<https://github.com/WalletConnect/walletconnect-monorepo/issues/748>

{% endhint %}

<figure><img src="https://2351247042-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9QQIPimQeOGE3C1HbWxf%2Fuploads%2FwRoNAjpSMs6ME6pLbXHg%2FZrzut%20ekranu%202023-03-4%20o%2008.07.45.png?alt=media&#x26;token=9a807fa6-a148-49fc-9e70-f1933817a8b5" alt=""><figcaption><p>Buffer error</p></figcaption></figure>

{% tabs %}
{% tab title="npm" %}

```
npm install buffer
```

{% endtab %}

{% tab title="yarn" %}

```
yarn add buffer
```

{% endtab %}
{% endtabs %}

```typescript
import { Buffer } from 'buffer'

window.Buffer = window.Buffer || Buffer

function App() {...
```

### Connecting with built-in WalletConnect QRcode

```typescript
import { metapro } from 'yourPathToMetapro/connector'

const loginFunction = async () => {
    try {
        await metapro.activate(56)
    } catch (e) {
        customErrorHandler()
    }
}
```

### Connecting with custom QRcode

{% code overflow="wrap" lineNumbers="true" %}

```typescript
import React, { useState, useEffect } from 'react'
import { metapro } from 'yourPathToMetapro/connector'

function HomePage() {

  const [qrCodeUri, setQrCodeUri] = useState<string>()
  const [qrCodeOpen, setQrCodeOpen] = useState<boolean>(false)
  
  //We can get wallet address from the web3react hook
  const {account} = useWeb3React()

  useEffect(() => {
    if (metapro.provider?.connector.uri) {
      setQrCodeUri(metapro.provider?.connector.uri)
      setQrCodeOpen(true)
    }     
  }, [metapro.provider?.connector.uri])

  const loginFunction = async () => {
    try {
      await metapro.activate(56)
      setQrCodeOpen(true)
    } catch (e) {
      metapro.deactivate()
      customErrorHandler()
    }
  }
  
  const logoutFunction = async () => {
    try {
      await metapro.deactivate()
    } catch (e) {
      customErrorHandler()
    }
  }
  return (
    <>
      <button onClick={loginFunction}>
         Login
      </button>
      <button onClick={loginFunction}>
         Logout
      </button>
      <p>Your wallet {account}</p>
      <QRCodeComponent uri={qrCodeUri} open={qrCodeOpen} />
    </>
  );
}
```

{% endcode %}

### Hook to connect eagerly on application start

```typescript
import { metapro } from 'yourPathToMetapro/connector'

const useEagerConnect = () => {
  useEffect(() => {
    metapro.connectEagerly()
  }, [])
}
```
