appendClientMessage()

Appends a client Message object to an existing array of UI messages. If the last message in the array has the same ID as the new message, it will replace the existing message instead of appending. This is useful for maintaining a unified message history in a client-side chat application, especially when updating existing messages.

Import

import { appendClientMessage } from "ai"

API Signature

Parameters

messages:

Message[]

message:

Message

Returns

Message[]:

Array