# Establishing a Connection

Once an application has detected the provider, it can then request to connect to Jelli. This connection request will prompt the user for permission to share their public key, indicating that they are willing to interact further. Users must approve a connection request before the app can make additional requests such as signing a message or sending a transaction.

Once permission is established for the first time, the web application's domain will be whitelisted for future connection requests. After a connection is established, it is possible to terminate the connection from both the application and the user side.

#### Connecting

The **recommended and easiest** way to connect to Jelli is by calling:

```js
window.jelli.solana.connect()
```

However, the provider also exposes a `request` JSON RPC interface.

```js
const provider = getProvider(); // see "Detecting the Provider"
try {
  const resp = await provider.connect();
  console.log(resp.publicKey.toString());
  // 26qv4GCcx98RihuK3c4T6ozB3J7L6vWCuFVc7Ta2A3Uo
} catch (err) {
  // { code: 4001, message: 'User rejected the request.' }
}
```

The `connect()` call will return a Promise that resolves when the user accepts the connection request, and rejects (throw when awaited) when the user declines or closes the pop-up.

When the user accepts the request to connect, the provider will also emit a `connect` event:

```js
provider.on("connect", () => console.log("connected!"));
```

Once the web application is connected to Jelli, it will be able to read the connected account’s public key and prompt the user for additional transactions. It also exposes a convenient `isConnected` boolean:

```js
console.log(provider.publicKey.toString());
// 26qv4GCcx98RihuK3c4T6ozB3J7L6vWCuFVc7Ta2A3Uo

console.log(provider.isConnected);
// true
```
