examples/vue/simple-nuxt3
| Name | Last commit message | Last commit date |
|---|---|---|
| .. | ||
README.md
TanStack Vue Query Simple Example (Nuxt 3)#
Fetches a single GitHub repository and shows its stats.
Built with Nuxt 3.
How it works#
services/repos/queries.tsdefinesreposQueries.detail(), aqueryOptionsfactory keyed by['repos', 'detail']that fetches theTanStack/queryrepository from the GitHub API.app.vuereads it withuseQuery(reposQueries.detail())and callsawait suspense()in<script setup>, so the repository is fetched during server rendering.plugins/vue-query.tsis a Nuxt plugin that creates aQueryClientwith a 5-secondstaleTimeand installsVueQueryPlugin. On the server it storesdehydrate(queryClient)inuseState('vue-query')onapp:rendered, and on the client it callshydratewith that state onapp:created.
To run this example:
npm installnpm run dev