# connect

Start a new WalletConnect session with Joey.

`connect` opens the connect modal (Reown AppKit, with Joey featured first) and resolves once the user approves in Joey.

```ts
const { actions } = useProvider();
const { data, error } = await actions.connect();
```

## Parameters (optional)

```ts
{
  chain?: string;              // e.g. 'xrpl:0'
  pairing?: { topic: string }; // reuse an existing pairing
  openModal?: boolean;         // default true; false to use your own UI
}
```

## Returns

```ts
Promise<{
  data: SessionTypes.Struct | null; // the new WalletConnect session
  error: Error | null;
}>
```

## Example

```tsx
'use client';

import { useProvider } from './provider';

export function ConnectButton() {
  const { actions, session, accounts } = useProvider();

  const handleConnect = async () => {
    const { error } = await actions.connect();
    if (error) throw error;
  };

  if (session) {
    return (
      <div>
        <p>Connected</p>
        {accounts?.map((account) => <div key={account}>{account}</div>)}
      </div>
    );
  }
  return <button onClick={handleConnect}>Connect</button>;
}
```

> [!NOTE]
> A Joey session covers the account and network that are active in Joey when the user approves. If the user switches either, Joey ends the session. See [Events](/docs/integration/supported-networks/xrp-ledger/events).
