examples/lit/star-wars-lit-labs-router
| Name | Last commit message | Last commit date |
|---|---|---|
| .. | ||
README.md
TanStack Lit Query Star Wars Example (@lit-labs/router)#
A multi-page Star Wars app with films and characters, where each page fetches its own data.
Built with @lit-labs/router.
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/app-layout.tsdefines the@lit-labs/routerroutes, andsrc/film-list.tsandsrc/character-list.tsload their lists withcreateQueryController.src/character-detail.tsloads one character, then renders<character-film>(src/character-film.ts) and<character-homeworld>(src/character-homeworld.ts) elements that each callcreateQueryControllerwith their own detail query.src/film-detail.tsdoes the same for the film's characters withsrc/film-character.ts, so a character seen on one page is already cached when it shows up on another.
To run this example:
npm installnpm run dev