examples/solid/auto-refetching-solid-start2
| Name | Last commit message | Last commit date |
|---|---|---|
| .. | ||
README.md
TanStack Solid Query Auto Refetching Example (SolidStart)#
A todo list that polls the server with refetchInterval. Adding a todo or clearing the list invalidates the query.
Built with SolidStart.
How it works#
src/services/todos/queries.tsdefinestodosQueries.list()withqueryOptions, keyed by['todos', 'list'], andtodosMutations.create()andtodosMutations.deleteAll()withmutationOptions.src/services/todos/api.tskeeps the list in server memory. Each function is a SolidStart server function marked with'use server'.src/routes/index.tsxpasses the list options touseQuerywithrefetchIntervalbound to a signal, so changing the interval input changes how often the query refetches. Both mutations callqueryClient.invalidateQueries({ queryKey: todosQueries.all() })inonSuccess.src/app.tsxcreates theQueryClientand provides it withQueryClientProvideraround the SolidStart router.
To run this example:
npm installnpm run dev