Prompt Buddy logoPrompt Buddy

vercel · Vercel AI SDK Docs

AI SDK UI: Chatbot Message Persistence

Implements a mechanism to persist chatbot message history by integrating with external storage or local state to maintain conversation continuity across sessions.

Import to Prompt Buddy

Derived skill

Files assembled from official documentation

Viewing SKILL.md

AI SDK UI: Chatbot Message Persistence

Implements a mechanism to persist chatbot message history by integrating with external storage or local state to maintain conversation continuity across sessions.

When To Use

Use when you need to implement a way to save and reload chat message history so that users do not lose their conversation context when refreshing the page or returning later.

Reference Files

FileContainsUse For
SKILL.mdEntry point: scope, routing table, and workflow.Start here.
docs/ai-sdk-ui-chatbot-message-persistence-workflow-guide.mdA guide explaining how to implement message storage and retrieval for chatbots using the AI SDK UI components.Questions about a guide explaining how to implement message storage and retrieval for chatbots using the AI SDK UI components.
examples/ai-sdk-ui-chatbot-message-persistence-vercel-ai-sdk-ui-chatbot-message-p.textA Next.js page component that creates a new chat session and redirects the user to the specific chat ID.Exact payloads, commands, or snippets shown in A Next.js page component that creates a new chat session and redirects the user to the specific chat ID.
examples/ai-sdk-ui-chatbot-message-persistence-nodejs-fs-implementation.textA Node.js implementation using the fs module to create and manage chat message files with unique IDs.Exact payloads, commands, or snippets shown in A Node.js implementation using the fs module to create and manage chat message files with unique IDs.
examples/ai-sdk-ui-chatbot-message-persistence-nodejs-load-chat.textA Node.js code example demonstrating how to load chatbot message history from a local file using the AI SDK UIMessage type.Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to load chatbot message history from a local file using the AI SDK UIMessage...
examples/ai-sdk-ui-chatbot-message-persistence.textA TypeScript code example demonstrating how to persist chatbot messages using the AI SDK UI components and custom chat store utilities.Exact payloads, commands, or snippets shown in A TypeScript code example demonstrating how to persist chatbot messages using the AI SDK UI components and custom cha...
examples/ai-sdk-ui-chatbot-message-persistence-typescript.textA TypeScript code example demonstrating how to load, validate, and persist chatbot messages using the AI SDK UI.Exact payloads, commands, or snippets shown in A TypeScript code example demonstrating how to load, validate, and persist chatbot messages using the AI SDK UI.
examples/ai-sdk-ui-chatbot-message-persistence-nextjs-page.textA Next.js page component demonstrating how to load and render chat messages from a persistent store using the AI SDK UI.Exact payloads, commands, or snippets shown in A Next.js page component demonstrating how to load and render chat messages from a persistent store using the AI SDK UI.
examples/ai-sdk-ui-chatbot-message-persistence-react.textA React client component demonstrating how to implement message persistence in a chatbot interface using the AI SDK UI hooks.Exact payloads, commands, or snippets shown in A React client component demonstrating how to implement message persistence in a chatbot interface using the AI SDK U...
examples/ai-sdk-ui-chatbot-message-persistence-typescript-2.textA TypeScript code example demonstrating how to implement chatbot message persistence using the AI SDK UI by saving chat history to a store.Exact payloads, commands, or snippets shown in A TypeScript code example demonstrating how to implement chatbot message persistence using the AI SDK UI by saving ch...
examples/ai-sdk-ui-chatbot-message-persistence-save-chat-function.textA TypeScript function that serializes UIMessage arrays to a JSON file using the fs/promises module.Exact payloads, commands, or snippets shown in A TypeScript function that serializes UIMessage arrays to a JSON file using the fs/promises module.
examples/ai-sdk-ui-chatbot-message-persistence-2.textA TypeScript code example demonstrating how to use createIdGenerator and toUIMessageStreamResponse to ensure consistent message IDs for chatbot persistence.Exact payloads, commands, or snippets shown in A TypeScript code example demonstrating how to use createIdGenerator and toUIMessageStreamResponse to ensure consiste...
examples/ai-sdk-ui-chatbot-message-persistence-route-handler.textA TypeScript implementation of a POST route handler using createUIMessageStream to manage chatbot message persistence.Exact payloads, commands, or snippets shown in A TypeScript implementation of a POST route handler using createUIMessageStream to manage chatbot message persistence.
examples/ai-sdk-ui-chatbot-message-persistence-usechat-id-generator.textA code example demonstrating how to use the createIdGenerator function within the useChat hook to customize message ID generation.Exact payloads, commands, or snippets shown in A code example demonstrating how to use the createIdGenerator function within the useChat hook to customize message I...
examples/ai-sdk-ui-chatbot-message-persistence-usechat-transport.textA React code example demonstrating how to use the useChat hook with a custom DefaultChatTransport to implement message persistence by sending only the latest message to the server.Exact payloads, commands, or snippets shown in A React code example demonstrating how to use the useChat hook with a custom DefaultChatTransport to implement messag...
examples/ai-sdk-ui-chatbot-message-persistence-3.textA TypeScript code example demonstrating how to load and validate previous chat messages using convertToModelMessages and validateUIMessages within a POST request handler.Exact payloads, commands, or snippets shown in A TypeScript code example demonstrating how to load and validate previous chat messages using convertToModelMessages...
examples/ai-sdk-ui-chatbot-message-persistence-4.textA TypeScript code example demonstrating how to persist chatbot messages using the AI SDK UI and a custom chat store.Exact payloads, commands, or snippets shown in A TypeScript code example demonstrating how to persist chatbot messages using the AI SDK UI and a custom chat store.

What This Skill Covers

  • Being able to store and load chat messages is crucial for most AI chatbots. In this guide, we'll show how to implement message persistence with useChat and s...
  • Main sections: Starting a new chat, Loading an existing chat, Validating messages on the server, Validation with tools, Handling validation errors.

Workflow

  1. Open the most relevant file under docs/ for the exact documented workflow and wording.
  2. Open schemas/ files for exact structured contracts.
  3. Open examples/ files for concrete requests, commands, snippets, and manifests.
  4. Do not add behavior or configuration that is not present in the attached source files.

Canonical source: https://ai-sdk.dev/docs/ai-sdk-ui/chatbot-message-persistence