Can someone help me with an example of a React-Native app that connects to Metamask using the Metamask React-Native SDK?

Hi, I am working on a project that just needs to retrieve the user’s public address from the MetaMask wallet into my project app. I Had the sample app linked in the documentation running and it was working fine just few days back. But now the app is stuck on the MetaMask wallet app and doesn’t return to the app. It’d be greatly helpful if someone could help me with this issue.

This is the code I am trying to run from the MetaMask React-Native sdk demo App.

const connect = async () => { 
  try { 
  console.log('Connection Started:::::::'); 
   const result = await ethereum.request({method: 'eth_requestAccounts'}); 
   console.log('RESULT', result?.[0]); 
    } catch (e) { console.log('ERROR', e); } 

Hello @Ananthapadmanabhan, welcome to MetaMask community!

Have you checked for a possible solution in the MetaMask Docs or on the Github repository?

Would you also open an issue on Github, the one above?

There is also a Discord server for all matters relating to the SDK, for devs. Might prove useful to you.

1 Like

Hello @Ananthapadmanabhan )

I usually use the following method to display the public address in the user interface:

export const handler = (web3) => () => {

  const { data, error, mutate, } = useSWR(
    web3 ? "web3/useAcccount" : null,
    async () => {
      const accounts = await web3.eth.getAccounts();

      const account = accounts[0];
      if (!account) {
        throw new Error("doesn't exist any accounts");
      return account;

       return {
         account: data

The data object contains all the necessary changes that we can receive from our hook in the functional component


Hi, Thanks for the reply, But I believe that this is a method for React and not React-Native. I was looking for a solution specific to React-Native.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.