examples/vue/chat
| Name | Last commit message | Last commit date |
|---|---|---|
| .. | ||
README.md
TanStack Vue Query Chat Example#
A chat UI that streams the answer into the query cache with streamedQuery.
How it works#
src/services/messages/api.tsreturns an async iterable that yields a canned answer one word at a time with a random delay, and stops when thesignalaborts.src/services/messages/queries.tsdefinesmessagesQueries.detail(id, question), aqueryOptionsfactory whosequeryFnisexperimental_streamedQuery(imported asstreamedQuery). Each yielded word is appended todata, andstaleTime: Infinitykeeps a finished answer from refetching.src/ChatMessage.vuepasses a getter touseQueryfor one question and rendersdatajoined into a sentence, withisFetchingmarking the answer as still in progress.src/App.vueadds a question with a newcrypto.randomUUID()id on submit, so every question gets its own query.
To run this example:
npm installnpm run dev