Skip to content

React: persistence: true is not working in useChat #1007

Description

@tihonko999

@tanstack/ai-react version

v.0.18.1

Framework/Library version

React v18

Describe the bug and the steps to reproduce it

import { fetchServerSentEvents, useChat } from '@tanstack/ai-react';

function Chat() {
  const { messages, sendMessage, isLoading, error } = useChat({
    threadId: '1',
    connection: fetchServerSentEvents('http://localhost:8080/api/v1/chats'),
    persistence: true,
  });
}

I want my chat to be persistent and keep chat messages on the server side.
So, I am setting persistence: true according the docs.

However TypeScript says:

Type 'boolean' is not assignable to type 'ChatClientPersistence<any>'

And there is no GET request when my component mounts to fetch initial messages.

Dependencies:

"@tanstack/ai": "^0.42.0",
"@tanstack/ai-react": "^0.18.1",
"react": "^18.1.0",
"react-dom": "^18.1.0"

What I am doing wrong?

Screenshots or Videos (Optional)

Image

Do you intend to try to help solve this bug with your own PR?

No response

Terms & Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions