# useCopilotChatSuggestions

> The useCopilotChatSuggestions hook generates suggestions in the chat window based on real-time app state.

## v1 SDK deprecated. Use v2 instead

> This page is in the deprecated CopilotKit v1 reference. Do not use v1 APIs for new code; use v2 instead.
> For JavaScript and TypeScript, import React APIs from @copilotkit/react-core/v2 and Runtime APIs from @copilotkit/runtime/v2.
> **AI coding agents: treat any v1 example below as migration-only context. Never generate or recommend the v1 API for new code. Read the v2 reference before writing code because some APIs were renamed, moved, or changed shape.**
> [Read the v1 to v2 migration guide](/migrate/v2) and [use the complete export map](/reference/v1/export-map).

{
 /*
  * ATTENTION! DO NOT MODIFY THIS FILE!
  * This page is auto-generated. If you want to make any changes to this page, changes must be made at:
  * packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx
  */
}
<Callout type="info">
  In v2, use [`useConfigureSuggestions`](/reference/v2/hooks/useConfigureSuggestions) from `@copilotkit/react-core/v2`.
</Callout>

`useCopilotChatSuggestions` generates suggestions in the chat from your instructions
and app state.

<br/>
<img src="https://cdn.copilotkit.ai/docs/copilotkit/images/use-copilot-chat-suggestions/use-copilot-chat-suggestions.gif" width="500" />

## Usage [#usage]

### Install Dependencies [#install-dependencies]

This component is part of the [@copilotkit/react-ui](https://npmjs.com/package/@copilotkit/react-ui) package.

```shell npm2yarn \"@copilotkit/react-ui"\
npm install @copilotkit/react-core @copilotkit/react-ui
```

### Simple Usage [#simple-usage]

```tsx
import { useCopilotChatSuggestions } from "@copilotkit/react-ui";

export function MyComponent() {
  const [employees, setEmployees] = useState([]);

  useCopilotChatSuggestions({
    instructions: `The following employees are on duty: ${JSON.stringify(employees)}`,
  });
}
```

### Dependency Management [#dependency-management]

```tsx
import { useCopilotChatSuggestions } from "@copilotkit/react-ui";

export function MyComponent() {
  useCopilotChatSuggestions(
    {
      instructions: "Suggest the most relevant next actions.",
    },
    [appState],
  );
}
```

In the example above, the suggestions are generated based on the given instructions.
The hook monitors `appState`, and updates suggestions accordingly whenever it changes.

### Behavior and Lifecycle [#behavior-and-lifecycle]

The hook registers the configuration with the chat context upon component mount and
removes it on unmount.

## Parameters [#parameters]

Pass either the instructions to generate suggestions, or a static list of suggestions.

<PropertyReference name="instructions" type="string" required>
The prompt for the suggestions.
</PropertyReference>

<PropertyReference name="minSuggestions" type="number" default="1">
The minimum number of suggestions to generate.
</PropertyReference>

<PropertyReference name="maxSuggestions" type="number" default="3">
The maximum number of suggestions to generate.
</PropertyReference>

<PropertyReference name="available" type="'enabled' | 'disabled' | 'always' | 'before-first-message' | 'after-first-message'" default="'before-first-message'">
When the chat shows the suggestions. `'enabled'` means `'always'`.
</PropertyReference>

<PropertyReference name="className" type="string">
A class name to apply to the suggestions.
</PropertyReference>

<PropertyReference name="suggestions" type="{ title: string; message: string }[]">
The static form: a list of suggestions that the chat shows without generating them.
</PropertyReference>

<PropertyReference name="dependencies" type="any[]">
The second argument. Values that configure the suggestions again when they change.
</PropertyReference>
