getPage()

Environment: Browser

The getPage() function provides pageContext in the browser-side.

// *.page.client.js
// Environment: Browser

import { getPage } from 'vite-plugin-ssr/client'

hydrate()

async function hydrate() {
  const pageContext = await getPage()
  /* ... */
}

The pageContext provided by getPage() is a subset of the pageContext defined on the server-side; to determine what pageContext is sent to the browser we use passToClient.

The pageContext is serialized and passed from the server to the browser with devalue.

In development getPage() dynamically lazy-loads the page, while in production the page is preloaded (with <link rel="preload">).

Edit this page