What problem does it solve?
Chat UIs built with useChat or ChatClient lose their entire message history, pending tool approvals, and in-flight streams when the user reloads the page. This Skill explains how to persist chat state per threadId so reloads restore transcripts, pending interrupts, and mid-stream runs.
Core Features & Use Cases
- Browser storage adapters: localStoragePersistence, sessionStoragePersistence, and indexedDBPersistence cache the full transcript client-side for SPA reload durability.
- Server-authoritative mode: Setting persistence: true hydrates the thread from the server by threadId on mount, caching nothing in the browser — ideal for multi-device and compliance-sensitive apps.
- Generation hook hydration: useGenerateImage, useGenerateVideo, and similar hooks restore status, result, and error for the last generation under a required threadId, with optional artifactUrl mapping to restore media bytes from your own origin.
- Use Case: A support chat SPA where users frequently refresh the page — add localStoragePersistence() with a stable threadId so the full conversation and any pending approval UI survive every reload.
Quick Start
Add localStoragePersistence() as the persistence option on my useChat hook with a stable threadId so the chat transcript survives page reloads.