Open History to see the last commit
1# TanStack Solid Query Auto Refetching Example (SolidStart)
2β
3A todo list that polls the server with `refetchInterval`. Adding a todo or clearing the list invalidates the query.
4β
5Built with [SolidStart](https://start.solidjs.com).
6β
7## How it works
8β
9- `src/services/todos/queries.ts` defines `todosQueries.list()` with `queryOptions`, keyed by `['todos', 'list']`, and `todosMutations.create()` and `todosMutations.deleteAll()` with `mutationOptions`.
10- `src/services/todos/api.ts` keeps the list in server memory. Each function is a SolidStart server function marked with `'use server'`.
11- `src/routes/index.tsx` passes the list options to `useQuery` with `refetchInterval` bound to a signal, so changing the interval input changes how often the query refetches. Both mutations call `queryClient.invalidateQueries({ queryKey: todosQueries.all() })` in `onSuccess`.
12- `src/app.tsx` creates the `QueryClient` and provides it with `QueryClientProvider` around the SolidStart router.
13β
14To run this example:
15β
16- `npm install`
17- `npm run dev`