Gathering detailed insights and metrics for @hebilicious/vue-query-nuxt
Gathering detailed insights and metrics for @hebilicious/vue-query-nuxt
Gathering detailed insights and metrics for @hebilicious/vue-query-nuxt
Gathering detailed insights and metrics for @hebilicious/vue-query-nuxt
A lightweight, 0 config Nuxt Module for Vue Query.
npm install @hebilicious/vue-query-nuxt
Typescript
Module System
Node Version
NPM Version
27.3
Supply Chain
27.3
Quality
69.8
Maintenance
50
Vulnerability
92.6
License
TypeScript (90.97%)
Vue (9.03%)
Total Downloads
204,171
Last Day
433
Last Week
3,315
Last Month
16,712
Last Year
146,967
MIT License
103 Stars
108 Commits
9 Forks
2 Watchers
16 Branches
3 Contributors
Updated on Aug 15, 2025
Latest Version
0.3.0
Package Id
@hebilicious/vue-query-nuxt@0.3.0
Unpacked Size
19.59 kB
Size
5.93 kB
File Count
21
NPM Version
10.2.3
Node Version
18.19.0
Published on
Dec 19, 2023
Cumulative downloads
Total Downloads
Last Day
-23.9%
433
Compared to previous day
Last Week
-18.4%
3,315
Compared to previous week
Last Month
1.8%
16,712
Compared to previous month
Last Year
165%
146,967
Compared to previous year
2
1
🚀 Welcome to Vue Query Nuxt!
This Nuxt Module automatically installs and configure Vue Query for your Nuxt application. It has 0 config out-of-the box and extremely lightweight.
Refer to the Vue Query documentation for more information about Vue Query.
1# npm 2npm i @hebilicious/vue-query-nuxt @tanstack/vue-query 3# pnpm 4pnpm i @hebilicious/vue-query-nuxt @tanstack/vue-query 5# yarn 6yarn add @hebilicious/vue-query-nuxt @tanstack/vue-query
In nuxt.config.ts
:
1export default defineNuxtConfig({ 2 modules: ["@hebilicious/vue-query-nuxt"] 3})
In a vue component :
1<script setup lang="ts"> 2// Access QueryClient instance 3const queryClient = useQueryClient() 4 5// Query 6const { isLoading, isError, data, error } = useQuery({ 7 queryKey: ['todos'], 8 queryFn: () => $fetch("/api/todos"), // Use $fetch with your api routes to get typesafety 9}) 10 11// Mutation 12const { mutate } = useMutation({ 13 mutationFn: (newTodo) => $fetch("/api/todos", { method: "POST", body: newTodo }) 14 onSuccess: () => { 15 // Invalidate and refetch 16 queryClient.invalidateQueries({ queryKey: ['todos'] }) 17 }, 18}) 19 20function onButtonClick() { 21 mutate({ 22 id: Date.now(), 23 title: 'Do Laundry', 24 }) 25} 26</script> 27 28<template> 29 <span v-if="isLoading">Loading...</span> 30 <span v-else-if="isError">Error: {{ error.message }}</span> 31 <!-- We can assume by this point that `isSuccess === true` --> 32 <ul v-else> 33 <li v-for="todo in data" :key="todo.id">{{ todo.title }}</li> 34 </ul> 35 <button @click="onButtonClick">Add Todo</button> 36</template>
You can specify the options under the vueQuery key in your nuxt.config.ts file. Everything is typed.
In nuxt.config.ts
:
1export default defineNuxtConfig({
2 modules: ["@hebilicious/vue-query-nuxt"],
3 vueQuery: {
4 // useState key used by nuxt for the vue query state.
5 stateKey: "vue-query-nuxt", // default
6 // If you only want to import some functions, specify them here.
7 // You can pass false or an empty array to disable this feature.
8 // default: ["useQuery", "useQueries", "useInfiniteQuery", "useMutation", "useIsFetching", "useIsMutating", "useQueryClient"]
9 autoImports: ["useQuery"],
10 // Pass the vue query client options here ...
11 queryClientOptions: {
12 defaultOptions: { queries: { staleTime: 5000 } } // default
13 },
14 // Pass the vue query plugin options here ....
15 vueQueryPluginOptions: {}
16 }
17})
If you need to modify the plugin that installs vue query, you can create a vue-query.config.ts
file at the root of your project.
In vue-query.config.ts
:
1import { library } from "@example/libray" 2 3export default defineVueQueryPluginHook(({ queryClient, nuxt }) => { 4 console.log(queryClient, nuxt) // You can access the queryClient here 5 return { 6 pluginReturn: { provide: { library, test: console } }, // nuxt plugin return value 7 vueQueryPluginOptions: { queryClient } // You can pass dynamic options 8 } 9})
This hook will be run within the nuxt plugin installed by the module, so you can use it to provide
something or replace the vue query options.
This can be useful if you need to run custom logic when the queryClient
is being installed.
Contributions, issues and feature requests are welcome!
Fork this repo
Install node
and pnpm
Use corepack enable && corepack prepare pnpm@latest --activate
to install pnpm easily
Use pnpm i
at the mono-repo root.
Make modifications and follow conventional commits.
Open a PR 🚀🚀🚀
No vulnerabilities found.