Skip to content

UseNextChatOptions

Defined in: react-nextjs/src/client.ts:20

Extended options for Next.js useChat.

optional api: string

Defined in: react-core/dist/types/types.d.ts:117

API endpoint for chat

UseChatOptions.api


optional body: Record<string, unknown>

Defined in: react-core/dist/types/types.d.ts:121

Request body extras

UseChatOptions.body


optional direct: DirectModeOptions

Defined in: react-core/dist/types/types.d.ts:130

Direct backend mode configuration. When provided, bypasses HTTP and uses the backend adapter directly.

UseChatOptions.direct


optional experimental: object

Defined in: react-nextjs/src/client.ts:24

Experimental features

optional partialHydration: boolean

Enable partial hydration

optional suspense: boolean

Enable React Suspense


optional generateId: () => string

Defined in: react-core/dist/types/types.d.ts:132

Generate unique message IDs

string

UseChatOptions.generateId


optional headers: Record<string, string>

Defined in: react-core/dist/types/types.d.ts:119

Request headers

UseChatOptions.headers


optional id: string

Defined in: react-core/dist/types/types.d.ts:115

Chat ID for persistence

UseChatOptions.id


optional initialInput: string

Defined in: react-core/dist/types/types.d.ts:113

Initial input value

UseChatOptions.initialInput


optional initialMessages: Message[]

Defined in: react-core/dist/types/types.d.ts:111

Initial messages

UseChatOptions.initialMessages


optional keepLastMessageOnError: boolean

Defined in: react-core/dist/types/types.d.ts:138

Keep last message on error

UseChatOptions.keepLastMessageOnError


optional maxToolRoundtrips: number

Defined in: react-core/dist/types/types.d.ts:140

Max number of automatic tool retries

UseChatOptions.maxToolRoundtrips


optional onError: (error) => void

Defined in: react-core/dist/types/types.d.ts:136

Called on error

Error

void

UseChatOptions.onError


optional onFinish: (message) => void

Defined in: react-core/dist/types/types.d.ts:134

Called when response stream finishes

Message

void

UseChatOptions.onFinish


optional onResponse: (response) => void

Defined in: react-core/dist/types/types.d.ts:125

Called for each response chunk (HTTP mode only)

Response

void

UseChatOptions.onResponse


optional sendExtraMessageFields: boolean

Defined in: react-core/dist/types/types.d.ts:142

Send extra message fields

UseChatOptions.sendExtraMessageFields


optional serverAction: (body) => Promise<unknown>

Defined in: react-nextjs/src/client.ts:22

Use server action instead of API route

unknown

Promise<unknown>


optional streamProtocol: "text" | "data"

Defined in: react-core/dist/types/types.d.ts:123

Stream protocol

UseChatOptions.streamProtocol