You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Pages: one pages/_app setup hook for Vue, React, Svelte, and Solid #941
#915 asks for a place to install Vue plugins such as Pinia, and #936 adds one for Vue only.
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.
exportdefaultfunctionsetup({ 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. In React, for example:
// pages/_app.tsximport{QueryClient,QueryClientProvider,dehydrate,hydrate}from'@tanstack/react-query';exportdefaultfunctionsetup(){constclient=newQueryClient();return{Providers: ({ children })=><QueryClientProviderclient={client}>{children}</QueryClientProvider>,dehydrate: ()=>dehydrate(client),hydrate: (state)=>hydrate(client,state),};}
Svelte needs props, because a Providers component written in .svelte can't reach objects created in setup.
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 }).
Activity