<p>Above simple solution will work, but you could expand it more like:</p>
<ul>
<li>check if the window.cardano API is available</li>
<li>loop through all wallets to check if they are installed</li>
<li>check if they are enabled, there is a isEnabled() function which can be used.</li>
</ul>
<p>With this feedback you can give the end-user a dropdown where you list all wallets and enable/highlight the ones that are available.</p>

CC BY-SA 4.0
2022-08-05T10:12:03.583Z
2022-08-05T10:12:03.583Z
Michiel Bellen
<p>The simplest solution I had is to use a cookie which you set once you grants you permission. Then, as a user visits your page, you just read the cookie and get the selected wallet.</p>

CC BY-SA 4.0
2022-08-05T09:20:16.717Z
2022-08-05T09:20:16.717Z
Will
<p>I am currently connecting to a cardano wallet like this.</p>
<pre><code>  const [walletApiKey, setWalletApiKey] = useState(null);

  const connectCardanoWallets = async (selectedWallet) =&gt; {
    const walletFound = !!window?.cardano?.[selectedWallet];
    if (walletFound) {
      try {
        let walletApi;
        walletApi = await window.cardano[selectedWallet].enable();
        setWalletApiKey(walletApi);
      } catch (err) {
        console.log(err);
      }
    } else {
      toast('Wallet not found');
    }
  };
</code></pre>
<p>If they have previously connected to our website before , when I envoke the method .enable() we get the API key automatically without the user putting in their password to whitelist us again. Right now I am using a useEffect hook like this to connect to their wallet.</p>
<pre><code>  useEffect(() =&gt; {
    connectCardanoWallets('nami');
  }, []);
</code></pre>
<p>How do I check if our website is whitelisted so i can automatically connect to their wallet and don't automatically envoke the .enable() method if my website is not whitelisted?</p>

<wallet>
Automatically connect to wallet if website is whitelisted
# Automatically connect to wallet if website is whitelisted

(Asked by: username_0 on 2022-08-04)

I am currently connecting to a cardano wallet like this.
  const [walletApiKey, setWalletApiKey] = useState(null);

  const connectCardanoWallets = async (selectedWallet) => {
    const walletFound = !!window?.cardano?.[selectedWallet];
    if (walletFound) {
      try {
        let walletApi;
        walletApi = await window.cardano[selectedWallet].enable();
        setWalletApiKey(walletApi);
      } catch (err) {
        console.log(err);
      }
    } else {
      toast('Wallet not found');
    }
  };

If they have previously connected to our website before , when I envoke the method .enable() we get the API key automatically without the user putting in their password to whitelist us again. Right now I am using a useEffect hook like this to connect to their wallet.
  useEffect(() => {
    connectCardanoWallets('nami');
  }, []);

How do I check if our website is whitelisted so i can automatically connect to their wallet and don't automatically envoke the .enable() method if my website is not whitelisted?

**Tags:** wallet

---

## 2 answers

### Answer by username_1 on 2022-08-05. Score: 1

Above simple solution will work, but you could expand it more like:

* check if the window.cardano API is available
* loop through all wallets to check if they are installed
* check if they are enabled, there is a isEnabled() function which can be used.

With this feedback you can give the end-user a dropdown where you list all wallets and enable/highlight the ones that are available.


---

### Answer by username_2 on 2022-08-05. Score: 1

The simplest solution I had is to use a cookie which you set once you grants you permission. Then, as a user visits your page, you just read the cookie and get the selected wallet.


---

