# Connect

An app must first establish a connection with Solflare before it can begin interacting with it. This connection request will prompt the user to share their public key, indicating their willingness to interact further.

When a user connects to Solflare, Solfalre returns a session parameter, which should be used on all subsequent methods.&#x20;

{% hint style="info" %}
Please see [Handling Sessions](https://docs.solflare.com/solflare/technical/deeplinks/handling-sessions) for more information on sessions.
{% endhint %}

### Base URL

```
https://solflare.com/ul/v1/connect
```

### Query String Parameters

* `app_url` **(required)**: A URL that is used to retrieve app metadata (e.g., title, icon). URL-encoded.
* `dapp_encryption_public_key` **(required)**: A public key used for end-to-end encryption. This information will be used to generate a shared secret. Please see [Encryption](https://docs.solflare.com/solflare/technical/deeplinks/encryption) for more information on how Solflare handles shared secrets.
* `redirect_link` **(required)**: The URI to which Solflare should redirect the user when they connect. For more information, please see [Specifying Redirects](https://docs.solflare.com/solflare/technical/deeplinks/specifying-redirects). URL-encoded.
* `cluster` (optional): The network that should be used for subsequent interactions. Can be either: `mainnet-beta`, `testnet`, or `devnet`. Defaults to `mainnet-beta`.

### Returns

#### Approve

* `solflare_encryption_public_key`: A base58-encoded encryption public key used by Solflare to build a shared secret between the connecting app and Solflare.
* `nonce`: A nonce encoded in base58 that is used to encrypt the response.
* `data`: JSON string that has been encrypted. Learn how apps can decrypt data using a shared secret in [Encryption](https://docs.solflare.com/solflare/technical/deeplinks/encryption). Base58 is used to encode encrypted bytes.

  ```javascript
  // content of decrypted `data`-parameter
  {
    // base58 encoding of user public key
    "public_key": "3huUrtWW5s5ew98eUFRYz9LPsDUQTujNzzYaB9DBkppQ",

    // session token for subsequent signatures and messages
    // apps should send this with any other deeplinks after connect
    "session": "..."
  }
  ```

  * `public_key`: The user's public key, represented as a base58-encoded string.
  * `session`: A string encoded in base58. This should be treated as opaque by the connecting app, as it only needs to be passed alongside other parameters. Sessions do not expire. For more information on sessions, please review [Handling Sessions](https://docs.solflare.com/solflare/technical/deeplinks/handling-sessions).

#### Reject

An `errorCode` and `errorMessage` as query parameters.&#x20;

Please refer to [Errors](https://docs.solflare.com/solflare/technical/deeplinks/limitations#errors) for a full list of possible error codes.

### Example

Please refer to the [connect](https://github.com/solflare-wallet/deep-link-sample-app/blob/master/App.tsx#L183-L194) method implemented in our demo application.


---

# 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.solflare.com/solflare/technical/deeplinks/provider-methods/connect.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.
