> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hotglue.com/llms.txt
> Use this file to discover all available pages before exploring further.

# filter

> Load and show only specific flows or connectors

## filter

Pass `filter` to `useHotglue` to limit the widget to specific flows or connectors. The filter is applied when the widget initializes, so the widget only fetches the flows and connectors you ask for. This makes the widget ready faster, especially in environments with many flows.

The same filter is used by `<Widget />` and `<Connections />`, so you don't need to pass it to the components.

## Example (React)

```jsx theme={null}
import { useHotglue, Widget, Connections } from "@hotglue/widget";

export default function Integrations() {
  const { openWidget } = useHotglue({
    tenantId: "tenant-1",
    environmentId: "<ENV ID>",
    apiKey: "<PUBLIC API KEY>",
    filter: { flows: ["<FLOW ID>"] },
  });

  return (
    <div>
      <Widget />
      <Connections />
      <button onClick={() => openWidget()}>Open Widget</button>
    </div>
  );
}
```

## Example (JavaScript)

The CDN version accepts the same `filter` in its configuration:

```javascript theme={null}
const hotglue = new Hotglue({
  tenantId: 'tenant-1',
  environmentId: '<ENV ID>',
  apiKey: '<PUBLIC API KEY>',
  filter: { connectors: ['salesforce'] },
});
```

## Type and default

```typescript theme={null}
type WidgetFilter =
  | { connectors: string[]; flows?: string[] }
  | { connectors?: string[]; flows: string[] };
```

* **flows**: `Array<string>` (optional)
  * Flow IDs to load and show.
* **connectors**: `Array<string>` (optional)
  * Connector IDs to load and show.

`filter` is optional. When set, it must include `flows`, `connectors`, or both. When it is not set, the widget loads every flow in the environment.

## Behavior

* **Only `flows`:** only the listed flows are loaded. If any flow ID does not exist in the environment, initialization fails with an `InvalidFlowIdError` whose message lists the missing flow IDs.
* **Only `connectors`:** only the flows that contain at least one of the listed connectors are loaded.
* **Both `flows` and `connectors`:** `flows` decides which flows are loaded. `connectors` still restricts which connectors are shown in those flows.
* **A single connector:** when `connectors` has exactly one ID, the widget fetches only that linked connector instead of every linked connector in the flow. This is the common case when you open the widget for one connector, for example from a magic link.
* **`link()` for a flow outside the filter:** still works. The widget fetches that flow's connectors when `link()` is called.
* **Changing the tenant:** if `openWidget()` or `link()` receives a different `tenantId` than the current one, the widget reinitializes for that tenant with the same `filter`.

The filter is compared by value, so passing a new object literal on each render does not reinitialize the widget. Changing its contents does.

## Migrating from the component `filter` prop

> [!WARNING]
>
> The `filter` prop on `<Connections />` and `<Widget />` is deprecated. It still works, but it only hides flows and connectors after the widget has loaded all of them, so it does not make the widget faster.

Move the filter from the component to `useHotglue`:

```jsx theme={null}
// Before
useHotglue({ tenantId, environmentId, apiKey });
<Connections filter={{ flows: ["<FLOW ID>"] }} />

// After
useHotglue({ tenantId, environmentId, apiKey, filter: { flows: ["<FLOW ID>"] } });
<Connections />
```

We recommend using only the `useHotglue` filter. If you pass both, the `useHotglue` filter decides what is loaded and the component prop decides what is shown. A flow requested by the component prop that the `useHotglue` filter did not load is not shown.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.