# connect()

{% hint style="info" %}
This file documents the **main exports of the library**.
{% endhint %}

## connect(location, connector, options)

Connects and returns an `Organization` for `location`.

| Name               | Type                                                                                                         | Description                                                                                                                  |
| ------------------ | ------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------- |
| `location`         | `String`                                                                                                     | The Ethereum address or ENS domain of an Aragon organization.                                                                |
| `connector`        | `Connector` or `[String, Object]` or `String`                                                                | Accepts a `Connector` instance, and either a string or a tuple for embedded connectors and their config.                     |
| `options`          | `Object`                                                                                                     | The optional configuration object.                                                                                           |
| `options.ethereum` | `EthereumProvider`                                                                                           | An [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193) compatible object.                                                    |
| `options.network`  | [`Networkish`](/developers/tools/aragon-connect/api-reference/types.md#networkish)                           | The network to connect to. Defaults to `1`.                                                                                  |
| `options.ipfs`     | [`IpfsResolverDeclaration`](/developers/tools/aragon-connect/api-reference/types.md#ipfsresolverdeclaration) | The IPFS gateway and cached results. Defaults to `'https://ipfs.eth.aragon.network/ipfs/{cid}{path}'` and `40` respectively. |
| returns            | `Promise<Organization>`                                                                                      | An `Organization` instance.                                                                                                  |

This function can throw the following errors:

| Error type                                                                                                | Description                                       |
| --------------------------------------------------------------------------------------------------------- | ------------------------------------------------- |
| [`ErrorInvalidConnector`](/developers/tools/aragon-connect/api-reference/errors.md#errorinvalidconnector) | An unsupported or invalid connector was provided. |
| [`ErrorInvalidEthereum`](/developers/tools/aragon-connect/api-reference/errors.md#errorinvalidethereum)   | The Ethereum provider doesn’t seem to be valid.   |
| [`ErrorInvalidLocation`](/developers/tools/aragon-connect/api-reference/errors.md#errorinvalidlocation)   | The provided location doesn’t seem to be valid.   |
| [`ErrorInvalidNetwork`](/developers/tools/aragon-connect/api-reference/errors.md#errorinvalidnetwork)     | The network is incorrect or unsupported.          |

### Example

```javascript
import connect from '@aragon/connect'

// Connections should get wrapped in a try / catch to capture connection errors
try {
  // Connect to an org through The Graph
  const org1 = await connect('org1.aragonid.eth', 'thegraph')

  // Specify a different Chain ID
  const org3 = await connect('org3.aragonid.eth', 'thegraph', { network: 4 })

  // Specify a configuration for the connector
  const org3 = await connect('org3.aragonid.eth', [
    'thegraph',
    { orgSubgraphUrl: 'http://…' },
  ])

  // Custom connector
  const org4 = await connect(
    'org4.aragonid.eth',

    // CustomConnector implements IConnector
    new CustomConnector()
  )
} catch (err) {
  if (err instanceof ConnectionError) {
    console.error('Connection error')
  } else {
    console.error(err)
  }
}
```


---

# 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://legacy-docs.aragon.org/developers/tools/aragon-connect/api-reference/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.
