examples/solid/chat
| Name | Last commit message | Last commit date |
|---|---|---|
| .. | ||
README.md
TanStack Solid Query Chat Example#
A chat UI that streams the answer into the query cache with streamedQuery.
How it works#
src/services/messages/queries.tsdefinesmessagesQueries.detail(id, question)withqueryOptions. ItsqueryFnisstreamedQuery(imported asexperimental_streamedQuery), which appends each chunk fromstreamFntodataas it arrives, andstaleTime: Infinitykeeps a finished answer from being refetched.src/services/messages/api.tsreturns an async iterable that yields a canned answer word by word with random delays and stops when the query'ssignalis aborted.src/index.tsxrenders aChatMessageper question, which reads the streamed words fromuseQueryand joins them.isFetchingstaystrueuntil the stream ends, which shows the "..." indicator.
To run this example:
npm installnpm run dev