Skip to content

feat(vue): add an appSetup option for installing Vue plugins - #936

Open
hyfdev wants to merge 1 commit into
mainfrom
feat/vue-app-setup
Open

hyfdev wants to merge 1 commit into
mainfrom
feat/vue-app-setup

Conversation

@hyfdev

@hyfdev hyfdev commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Vue Pages has no place to install Vue plugins such as Pinia and vue-i18n.

voidVue({ appSetup: './src/vue-app.ts' }) now names a module whose default export Void calls with every Vue app it creates: once per request on the server, and in the browser once for the page and once per island.

// src/vue-app.ts
import { createPinia } from 'pinia';
import type { App } from 'vue';

export default function setup(app: App) {
  const pinia = createPinia();
  app.use(pinia);
  return {
    dehydrate: () => pinia.state.value,
    hydrate(state: typeof pinia.state.value) {
      pinia.state.value = state;
    },
  };
}

Void calls dehydrate() as soon as the page renders, before deferred data, and passes the result to hydrate() before the page mounts in the browser.

Islands start from the state their own setup creates, so server data reaches them as props.

Setup must be synchronous.

Fixes #915

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://feat-vue-app-setup-void-cloud.voidzero-docs.workers.dev (commit 46f9707)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://5c7abb94-void-cloud.voidzero-docs.workers.dev 46f9707 2026-11-27T12:52:36.769Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://b943db3f-void-cloud.voidzero-docs.workers.dev 4e71677 2026-11-27T11:24:33.366Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://dc1c7480-void-cloud.voidzero-docs.workers.dev 283b5b3 2026-11-27T07:52:05.166Z Visit the dashboard ↗
  • Build: Failed ❌

View logs ↗
6955086 2026-11-27T07:30:53.598Z View logs ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://d93c0401-void-cloud.voidzero-docs.workers.dev bd6b377 2026-11-27T00:30:26.942Z Visit the dashboard ↗

@hyfdev
hyfdev marked this pull request as ready for review November 27, 2026 00:40
Copilot AI balanced review requested due to automatic review settings November 27, 2026 00:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@hyfdev
hyfdev marked this pull request as draft November 27, 2026 00:45
@hyfdev
hyfdev force-pushed the feat/vue-app-setup branch from bd6b377 to 6955086 Compare November 27, 2026 07:30
@hyfdev
hyfdev changed the base branch from main to fix/svelte-island-hydration November 27, 2026 07:30
@hyfdev
hyfdev added this pull request to stack #945 November 27, 2026 07:30
@hyfdev
hyfdev force-pushed the feat/vue-app-setup branch from 6955086 to 283b5b3 Compare November 27, 2026 07:50
@hyfdev hyfdev changed the title feat(vue): add a pages/_app.ts setup hook for Vue plugins feat(pages): add a pages/_app setup hook for Vue, React, Svelte, and Solid Nov 27, 2026
@hyfdev hyfdev changed the title feat(pages): add a pages/_app setup hook for Vue, React, Svelte, and Solid feat(pages): add a pages/_app setup hook for Vue, React, Svelte, and Solid Nov 27, 2026
@hyfdev
hyfdev marked this pull request as ready for review November 27, 2026 08:32
@hyfdev
hyfdev requested a review from a team as a code owner November 27, 2026 08:32

@cpojer cpojer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this for every adapter, the others can already handle this via root layouts. Can we scope this to vue only through an opt-in like voidVue({ appSetup: './src/vue-app.ts' }).

@hyfdev
hyfdev removed this pull request from stack #945 November 27, 2026 11:23
@hyfdev
hyfdev changed the base branch from fix/svelte-island-hydration to main November 27, 2026 11:23
@hyfdev
hyfdev force-pushed the feat/vue-app-setup branch from 283b5b3 to 4e71677 Compare November 27, 2026 11:23
@hyfdev hyfdev changed the title feat(pages): add a pages/_app setup hook for Vue, React, Svelte, and Solid feat(vue): add an appSetup option for installing Vue plugins Nov 27, 2026
@hyfdev

hyfdev commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Scoped it to Vue, opted in with voidVue({ appSetup: './src/vue-app.ts' }).

@hyfdev
hyfdev requested a review from cpojer November 27, 2026 11:30

@cpojer cpojer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still two issues:

  • This change captures app state after deferred callbacks finish, which invalidates initial HTML. This would wipe away text a user has typed into when the rest of the page loads.
  • Islands can change the shared server store after an earlier island has already rendered and also erases user input. We should defer island state transfer until each island can hydrate with the state it rendered from.

@hyfdev
hyfdev force-pushed the feat/vue-app-setup branch from 4e71677 to 46f9707 Compare November 27, 2026 12:51
@hyfdev

hyfdev commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Both fixed.

dehydrate() now runs right after the page renders, before any deferred callback, and islands no longer receive app state; they get server data through props.

Both cases have browser tests now.

An island that reads store state changed on the server still mismatches, and the docs now say so.

@hyfdev
hyfdev requested a review from cpojer November 27, 2026 12:59

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

official way to install Vue plugins (app.use) in Pages apps

3 participants