# watchConnection | @account-kit/core

> Overview of the watchConnection function from @account-kit/core

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

{/* This file is auto-generated by TypeDoc. Do not edit manually. */}

```ts
function watchConnection(config): (onChange) => any;
```

Defined in: [account-kit/core/src/actions/watchConnection.ts:18](https://github.com/alchemyplatform/aa-sdk/blob/main/account-kit/core/src/actions/watchConnection.ts#L18)

Subscribe to changes to the active connection

## Example

```ts
import { watchConnection } from "@account-kit/core";
// see createConfig for more information on how to create a config
import { config } from "./config";

watchConnection(config)(console.log);
```

## Parameters

<table>
  <thead>
    <tr>
      <th align="left">Parameter</th>
      <th align="left">Type</th>
      <th align="left">Description</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `config`
      </td>

      <td>
        `AlchemyAccountsConfig`
      </td>

      <td>
        the account config
      </td>
    </tr>

  </tbody>
</table>

## Returns

a function which accepts an onChange callback that will be fired when the connection changes and returns a function to unsubscribe from the store

```ts
(onChange): any;
```

### Parameters

<table>
  <thead>
    <tr>
      <th align="left">Parameter</th>
      <th align="left">Type</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `onChange`
      </td>

      <td>
        (`connection`) => `void`
      </td>
    </tr>

  </tbody>
</table>

### Returns

`any`