examples/preact/star-wars-preact-iso
| Name | Last commit message | Last commit date |
|---|---|---|
| .. | ||
README.md
TanStack Preact Query Star Wars Example (preact-iso)#
A multi-page Star Wars app with films and characters, where each page fetches its own data.
Built with preact-iso.
How it works#
src/services/films/queries.ts,src/services/characters/queries.ts, andsrc/services/planets/queries.tsdefinequeryOptionsfactories (filmsQueries,charactersQueries,planetsQueries) for the Star Wars API.filmsQueries.detailusesskipTokenwhen there is no film id.src/Layout.tsxdefines thepreact-isoroutes, andsrc/Films.tsxandsrc/Characters.tsxload their lists withuseQuery.src/Character.tsxloads one character, then renders aFilmcomponent per film and aHomeworldcomponent that each calluseQuerywith their own detail query.src/Film.tsxdoes the same for the film's characters, so a character seen on one page is already cached when it shows up on another.
To run this example:
npm installnpm run dev