# Connect Directly to the ME Solana Provider

## Detecting the Provider

If you've built a custom wallet connection solution and want to add support for the Magic Eden Wallet, you can directly access the Solana Provider at `magicEden.solana` in the Window.

A code snippet to find the provider might look like the following:

```javascript
const getProvider = () => {
  // check if the magicEden object is available
  if ('magicEden' in window) {
    const magicProvider = window.magicEden?.solana;
    if (magicProvider?.isMagicEden) {
      return magicProvider;
    }
  }
  window.location.href = 'https://wallet.magiceden.io/'
};
```

The above will return the provider if the user has the extension installed, otherwise it'll redirect the user to the magic eden wallet website to download it.

## Connecting

Once the magicEden provider object has been found, a user is able to connect their wallet to the site. The connection request will prompt the user to approve the connection, so that their wallet can be used to make requests, such as sending transactions.

The easiest way to connect to the ME wallet is by calling `window.magicEden.solana.connect()`

```javascript
const provider = getProvider();

const handleConnect = async () => {
  try {
    await provider.connect();
  } catch (error) {
    console.error(error);
  }
};
```

The provider saves information like a user's pubkey once a connection has been established.

### More Info

A code demo for basic ME wallet connection can be found [here](https://github.com/Tcadle434/me-wallet-solana-react). A demo video can be found in the readme.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs-wallet.magiceden.io/solana/connect-directly-to-the-me-solana-provider.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
