Open History to see the last commit
1# TanStack Solid Query Rick And Morty Example (Solid Router)
2β
3A multi-page Rick and Morty app with characters and episodes, 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/episodes/queries.ts` and `src/services/locations/queries.ts` define `list()` and `detail(id)` factories with `queryOptions`, keyed by `['characters', ...]`, `['episodes', ...]` and `['locations', ...]`. The matching `api.ts` files fetch from the Rick and Morty API.
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/Episodes.tsx` read the lists, `src/Character.tsx` and `src/Episode.tsx` read a detail.
11- `src/Character.tsx` renders an `Episode` and a `Location` component per related id, each with its own `useQuery`, and `src/Episode.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`