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

# Frigade JS Type Definition

The `Frigade` class is the main entry point for the Frigade JS SDK. It is used to create a new instance of the Frigade SDK and to interact with the Frigade API.

The Step type is a representation of a step in a Flow.

It contains all the data and methods needed to build custom components with Frigade and to interact with the Frigade API without writing a single custom network call.

# Properties

### getCollections

▸ **getCollections**(): `Promise`\<`CollectionsList`>

***

### getConfig

▸ **getConfig**(): `FrigadeConfig`

Gets the current configuration.
See  [FrigadeConfig](https://github.com/FrigadeHQ/javascript/blob/main/packages/js-api/src/core/types.ts#L240) for a list of available options.

***

### getFlow

▸ **getFlow**(`flowId`): `Promise`\<`Flow`>

Get a Flow by its ID.

<b>Parameters</b>

| Name     | Type     |
| :------- | :------- |
| `flowId` | `string` |

***

### getFlows

▸ **getFlows**(): `Promise`\<`Flow`\[]>

***

### group

▸ **group**(`groupId?`, `properties?`): `Promise`\<`void`>

Set the group for the current user.

<b>Parameters</b>

| Name          | Type              |
| :------------ | :---------------- |
| `groupId?`    | `string`          |
| `properties?` | `PropertyPayload` |

***

### hasFailedToLoad

▸ **hasFailedToLoad**(): `boolean`

Returns true if the JS SDK failed to connect to the Frigade API.

***

### identify

▸ **identify**(`userId`, `properties?`): `Promise`\<`void`>

Set the current user.

<b>Parameters</b>

| Name          | Type              |
| :------------ | :---------------- |
| `userId`      | `string`          |
| `properties?` | `PropertyPayload` |

***

### off

▸ **off**(`event`, `handler`): `Promise`\<`void`>

Removes the given handler.

<b>Parameters</b>

| Name      | Type                     | Description                                                                                                                                      |
| :-------- | :----------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------- |
| `event`   | `FlowChangeEvent`        | `flow.any` \| `flow.complete` \| `flow.restart` \| `flow.skip` \| `flow.start` \| `step.complete` \| `step.skip` \| `step.reset` \| `step.start` |
| `handler` | `FlowChangeEventHandler` |                                                                                                                                                  |

***

### on

▸ **on**(`event`, `handler`): `Promise`\<`void`>

Event handler that captures all changes that happen to the state of the Flows. Use `flow.any` to capture all events.

<b>Parameters</b>

| Name      | Type                     | Description                                                                                                                                      |
| :-------- | :----------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------- |
| `event`   | `FlowChangeEvent`        | `flow.any` \| `flow.complete` \| `flow.restart` \| `flow.skip` \| `flow.start` \| `step.complete` \| `step.skip` \| `step.reset` \| `step.start` |
| `handler` | `FlowChangeEventHandler` |                                                                                                                                                  |

***

### onStateChange

▸ **onStateChange**(`handler`): `Promise`\<`void`>

Event handler that captures all changes that happen to the state of the Flows.

<b>Parameters</b>

| Name      | Type                                                |
| :-------- | :-------------------------------------------------- |
| `handler` | (`flow`: `Flow`, `previousFlow?`: `Flow`) => `void` |

**Deprecated**

Use `frigade.on` instead.

***

### registerCollection

▸ **registerCollection**(`collectionId`): `Promise`\<`void`>

<b>Parameters</b>

| Name           | Type     |
| :------------- | :------- |
| `collectionId` | `string` |

***

### reload

▸ **reload**(`config?`): `Promise`\<`void`>

Reload the current state of the flows by calling the Frigade API.
This will trigger all event handlers.

<b>Parameters</b>

| Name      | Type            | Description                                                                            |
| :-------- | :-------------- | :------------------------------------------------------------------------------------- |
| `config?` | `FrigadeConfig` | optional config to use when reloading. If not passed, the current config will be used. |

***

### removeStateChangeHandler

▸ **removeStateChangeHandler**(`handler`): `Promise`\<`void`>

Removes the given handler from the list of event handlers.

<b>Parameters</b>

| Name      | Type                                                |
| :-------- | :-------------------------------------------------- |
| `handler` | (`flow`: `Flow`, `previousFlow?`: `Flow`) => `void` |

***

### resync

▸ **resync**(): `Promise`\<`void`>

***

### track

▸ **track**(`event`, `properties?`): `Promise`\<`void`>

Track an event for the current user (and group if set).

<b>Parameters</b>

| Name          | Type              |
| :------------ | :---------------- |
| `event`       | `string`          |
| `properties?` | `PropertyPayload` |

***

### triggerAllEventHandlers

▸ **triggerAllEventHandlers**(): `void`

[View definition](https://github.com/FrigadeHQ/frigade-react/blob/b8996ad7/packages/js-api/src/core/frigade.ts#L393)
