@@ -148,26 +148,25 @@ Sync VueQuery client state with [vite-ssr](https://github.com/frandiox/vite-ssr)
148148// main.js (entry point)
149149import App from " ./App.vue" ;
150150import viteSSR from " vite-ssr/vue" ;
151- import { QueryClient , hydrate , dehydrate , VUE_QUERY_CLIENT } from " vue-query" ;
151+ import { QueryClient , VueQueryPlugin , hydrate , dehydrate } from " vue-query" ;
152152
153153export default viteSSR (App, { routes: [] }, ({ app, initialState }) => {
154154 // -- This is Vite SSR main hook, which is called once per request
155155
156156 // Create a fresh VueQuery client
157- const client = new QueryClient ();
157+ const queryClient = new QueryClient ();
158158
159159 // Sync initialState with the client state
160160 if (import .meta.env.SSR) {
161161 // Indicate how to access and serialize VueQuery state during SSR
162- initialState .vueQueryState = { toJSON : () => dehydrate (client ) };
162+ initialState .vueQueryState = { toJSON : () => dehydrate (queryClient ) };
163163 } else {
164164 // Reuse the existing state in the browser
165- hydrate (client , initialState .vueQueryState );
165+ hydrate (queryClient , initialState .vueQueryState );
166166 }
167167
168168 // Mount and provide the client to the app components
169- client .mount ();
170- app .provide (VUE_QUERY_CLIENT , client);
169+ app .use (VueQueryPlugin, { queryClient });
171170});
172171` ` `
173172
0 commit comments