Skip to content

Commit

Permalink
feat: support hydration option (#410) (#435)
Browse files Browse the repository at this point in the history
* feat: support hydrate option (#410)

* fix: rename

---------

Co-authored-by: Anthony Fu <github@antfu.me>
  • Loading branch information
BuptStEve and antfu authored Feb 18, 2025
1 parent d09ff78 commit 0c2d94f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ export function ViteSSG(
registerComponents = true,
useHead = true,
rootContainer = '#app',
hydration = false,
} = options
const isClient = typeof window !== 'undefined'

async function createApp(client = false, routePath?: string) {
const app = client
const app = client && !hydration
? createClientApp(App)
: createSSRApp(App)

Expand Down
3 changes: 2 additions & 1 deletion src/client/single-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ export function ViteSSG(
registerComponents = true,
useHead = true,
rootContainer = '#app',
hydration = false,
} = options
const isClient = typeof window !== 'undefined'

async function createApp(client = false) {
const app = client
const app = client && !hydration
? createClientApp(App)
: createSSRApp(App)

Expand Down
6 changes: 6 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ export interface ViteSSGClientOptions {
* @default `#app`
*/
rootContainer?: string | Element
/**
* Enable Vue hydration on client side
*
* @default false
*/
hydration?: boolean
}

export type RouterOptions = PartialKeys<VueRouterOptions, 'history'> & { base?: string }
Expand Down

0 comments on commit 0c2d94f

Please sign in to comment.