11# ⚗️ Vue Query Nuxt
22
33[ ![ CI] ( https://github.com/Hebilicious/vue-query-nuxt/actions/workflows/ci.yaml/badge.svg )] ( https://github.com/Hebilicious/vue-query-nuxt/actions/workflows/ci.yaml )
4- [ ![ npm version] ( https://badge.fury.io/js/@hebilicious%2Fvue -query-nuxt.svg )] ( https://badge.fury.io/js/@hebilicious%2Fvue -query-nuxt )
4+ [ ![ npm version] ( https://badge.fury.io/js/@hebilicious%20vue -query-nuxt.svg )] ( https://badge.fury.io/js/@hebilicious%20vue -query-nuxt )
55[ ![ License: MIT] ( https://img.shields.io/badge/License-MIT-yellow.svg )] ( https://opensource.org/licenses/MIT )
66
77🚀 Welcome to __ Vue Query Nuxt__ !
88
99This Nuxt Module automatically installs and configure Vue Query for your Nuxt application.
1010It has 0 config out-of-the box and extremely lightweight.
1111
12- ## ⚠️ Disclaimer
12+ ## Features
1313
14- _ 🧪 This module is in active development._
14+ - 0 config out-of-the box
15+ - All configurations options available
16+ - Auto Imports for Vue Query composables
1517
1618Refer to the [ Vue Query documentation] ( https://tanstack.com/query/latest/docs/vue/quick-start ) for more information about Vue Query.
1719
18- ## 📦 Installation
20+ ## 📦 How to use
1921
20-
21- 1 . Use npm, pnpm or yarn to install the dependencies.
22+ ### 1. Use npm, pnpm or yarn to install the dependencies.
2223
2324``` bash
25+ # npm
2426npm i @hebilicious/vue-query-nuxt @tanstack/vue-query
25- ```
26-
27- ``` bash
27+ # pnpm
2828pnpm i @hebilicious/vue-query-nuxt @tanstack/vue-query
29+ # yarn
30+ yarn add @hebilicious/vue-query-nuxt @tanstack/vue-query
2931```
3032
31- ``` bash
32- yarn i @hebilicious/vue-query-nuxt @tanstack/vue-query
33- ```
33+ ### 2. Add the modules to your Nuxt modules
3434
35- 2 . Add the modules to your Nuxt modules
35+ In ` nuxt.config.ts ` :
3636
3737``` ts
38- // In nuxt.config.ts
3938export default defineNuxtConfig ({
4039 modules: [" @hebilicious/vue-query-nuxt" ]
4140})
4241```
4342
44- 3 . Use right away
43+ ### 3. Use right away
4544
46- ``` html
47- <script setup >
48- import { useQueryClient , useQuery , useMutation } from ' @tanstack/vue-query'
45+ In a vue component :
4946
47+ ``` html
48+ <script setup lang =" ts" >
5049// Access QueryClient instance
5150const queryClient = useQueryClient ()
5251
@@ -84,28 +83,38 @@ function onButtonClick() {
8483</template >
8584```
8685
87- 4 . Advanced configuration
86+ ### 4. Advanced configuration
8887
8988You can specify the options under the vueQuery key in your nuxt.config.ts file.
9089Everything is typed.
9190
91+ In ` nuxt.config.ts ` :
92+
9293``` ts
93- // In nuxt.config.ts
9494export default defineNuxtConfig ({
9595 modules: [" @hebilicious/vue-query-nuxt" ],
9696 vueQuery: {
97- stateKey: " vue-query-nuxt" ,
97+ // useState key used by nuxt for the vue query state.
98+ stateKey: " vue-query-nuxt" , // default
99+ // If you only want to import some functions, specify them here.
100+ // You can pass false or an empty array to disable this feature.
101+ // default: ["useQuery", "useQueries", "useInfiniteQuery", "useMutation", "useIsFetching", "useIsMutating", "useQueryClient"]
102+ autoImports: [" useQuery" ],
103+ // Pass the vue query client options here ...
98104 queryClientOptions: {
99105 defaultOptions: { queries: { staleTime: 5000 } } // default
100106 },
107+ // Pass the vue query plugin options here ....
101108 vueQueryPluginOptions: {}
102109 }
103110})
104111```
112+
105113If 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.
106114
115+ In ` vue-query.config.ts ` :
116+
107117``` ts
108- // vue-query.config.ts
109118import { library } from " @example/libray"
110119
111120export default defineVueQueryPluginCallback ((vueQueryOptions ) => {
@@ -114,7 +123,7 @@ export default defineVueQueryPluginCallback((vueQueryOptions) => {
114123})
115124```
116125
117- This callback will be run * directly * after the Vue Query plugin is installed, so you can use it to ` provide ` something.
126+ This callback will be run _ directly _ after the Vue Query plugin is installed, so you can use it to ` provide ` something.
118127This can be useful if you want to configure something that needs the ` queryClient ` or you want to provide a library in the same plugin.
119128
120129## 📦 Contributing
0 commit comments