examples/solid/rick-morty-solid-router
| Name | Last commit message | Last commit date |
|---|---|---|
| .. | ||
README.md
TanStack Solid Query Rick And Morty Example (Solid Router)#
A multi-page Rick and Morty app with characters and episodes, where each page fetches its own data.
Built with Solid Router.
How it works#
src/services/characters/queries.ts,src/services/episodes/queries.tsandsrc/services/locations/queries.tsdefinelist()anddetail(id)factories withqueryOptions, keyed by['characters', ...],['episodes', ...]and['locations', ...]. The matchingapi.tsfiles fetch from the Rick and Morty API.src/App.tsxmaps each Solid Router route to a page component, and each page reads its own data withuseQuery:src/Characters.tsxandsrc/Episodes.tsxread the lists,src/Character.tsxandsrc/Episode.tsxread a detail.src/Character.tsxrenders anEpisodeand aLocationcomponent per related id, each with its ownuseQuery, andsrc/Episode.tsxdoes the same for characters. Details you have already opened come from the cache when you navigate back.
To run this example:
npm installnpm run dev