Repository navigation
Description
#915 asks for a place to install Vue plugins such as Pinia.
React, Svelte, and Solid apps need the same for providers such as TanStack Query, so the hook should have one shape across all four.
Proposal: pages/_app.ts, or .tsx/.jsx for JSX, default-exports a synchronous setup. Void calls it once per request on the server, and in the browser once for the page and once per island.
export default function setup({ app }) { // Vue gets { app }; React, Svelte, and Solid get {}
return {
Providers, // a component rendered around every page and island
props, // props for Providers
dehydrate, // called after the whole response is rendered
hydrate, // called before each browser root mounts
};
}Every field is optional. How each framework writes it:
Vue, installing Pinia and sending its state to the browser:
// pages/_app.ts
import { createPinia } from 'pinia';
import type { App } from 'vue';
export default function setup({ app }: { app: App }) {
const pinia = createPinia();
app.use(pinia);
return {
dehydrate: () => pinia.state.value,
hydrate: (state) => {
pinia.state.value = state;
},
};
}React, with TanStack Query:
// pages/_app.tsx
import { QueryClient, QueryClientProvider, dehydrate, hydrate } from '@tanstack/react-query';
export default function setup() {
const client = new QueryClient();
return {
Providers: ({ children }) => <QueryClientProvider client={client}>{children}</QueryClientProvider>,
dehydrate: () => dehydrate(client),
hydrate: (state) => hydrate(client, state),
};
}Svelte, with TanStack Query. Providers is a .svelte component, and it gets the client through props, because it can't reach objects created in setup:
// pages/_app.ts
import { QueryClient, dehydrate, hydrate } from '@tanstack/svelte-query';
import Providers from './_Providers.svelte';
export default function setup() {
const client = new QueryClient();
return {
Providers,
props: { client },
dehydrate: () => dehydrate(client),
hydrate: (state) => hydrate(client, state),
};
}Its file name starts with _, so Void doesn't treat it as a page:
<!-- pages/_Providers.svelte -->
<script lang="ts">
import { QueryClientProvider } from '@tanstack/svelte-query';
let { client, children } = $props();
</script>
<QueryClientProvider {client}>{@render children()}</QueryClientProvider>Solid, with TanStack Query:
// pages/_app.tsx
import { QueryClient, QueryClientProvider, dehydrate, hydrate } from '@tanstack/solid-query';
export default function setup() {
const client = new QueryClient();
return {
Providers: (props) => <QueryClientProvider client={client}>{props.children}</QueryClientProvider>,
dehydrate: () => dehydrate(client),
hydrate: (state) => hydrate(client, state),
};
}The state goes in its own script at the end of the body, after React's stream ends, so it stays out of prerendered page data.
For Vue, this changes #936's setup(app) to setup({ app }).
#936 implements it for all four frameworks.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
hyfdev commentedon Nov 27, 2026
Following cpojer's review on #936: React, Svelte, and Solid can do this with root layouts, so #936 now covers Vue only, opted in with
voidVue({ appSetup: './src/vue-app.ts' }).