From 7f8fcbbbdf21f995b94e75204bb87e981df25382 Mon Sep 17 00:00:00 2001 From: dengyongchi Date: Wed, 11 Dec 2024 00:27:11 +0800 Subject: [PATCH 1/2] feat: support hydrate option --- src/client/index.ts | 3 ++- src/types.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/client/index.ts b/src/client/index.ts index 989d652..543a6b8 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -21,11 +21,12 @@ export function ViteSSG( registerComponents = true, useHead = true, rootContainer = '#app', + isHydrate = false, } = options const isClient = typeof window !== 'undefined' async function createApp(client = false, routePath?: string) { - const app = client + const app = client && !isHydrate ? createClientApp(App) : createSSRApp(App) diff --git a/src/types.ts b/src/types.ts index 9ff2cb9..e164e49 100644 --- a/src/types.ts +++ b/src/types.ts @@ -159,6 +159,7 @@ export interface ViteSSGClientOptions { * @default `#app` */ rootContainer?: string | Element + isHydrate?: boolean } export type RouterOptions = PartialKeys & { base?: string } From 2d872f2cef7c61422ae44df6bf07cdcfb3f53433 Mon Sep 17 00:00:00 2001 From: dengyongchi Date: Wed, 11 Dec 2024 16:09:03 +0800 Subject: [PATCH 2/2] chore: add notes for isHydrate --- src/types.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/types.ts b/src/types.ts index e164e49..63a66a6 100644 --- a/src/types.ts +++ b/src/types.ts @@ -159,6 +159,10 @@ export interface ViteSSGClientOptions { * @default `#app` */ rootContainer?: string | Element + /** + * Enable Vue hydration on client side + * @default false + */ isHydrate?: boolean }