Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

README.md

16 lines1.1 KB

1# TanStack Solid Query Star Wars Example (Solid Router)
2​
3A multi-page Star Wars app with films and characters, where each page fetches its own data.
4​
5Built with [Solid Router](https://docs.solidjs.com/solid-router).
6​
7## How it works
8​
9- `src/services/characters/queries.ts`, `src/services/films/queries.ts` and `src/services/planets/queries.ts` define `list()` and `detail(id)` factories with `queryOptions` (`planetsQueries` only has `detail(id)`), keyed by `['characters', ...]`, `['films', ...]` and `['planets', ...]`. The matching `api.ts` files fetch from SWAPI.
10- `src/App.tsx` maps each Solid Router route to a page component, and each page reads its own data with `useQuery`: `src/Characters.tsx` and `src/Films.tsx` read the lists, `src/Character.tsx` and `src/Film.tsx` read a detail.
11- `src/Character.tsx` renders a `Film` and a `Homeworld` component per related id, each with its own `useQuery`, and `src/Film.tsx` does the same for characters. Details you have already opened come from the cache when you navigate back.
12​
13To run this example:
14​
15- `npm install`
16- `npm run dev`