getPage()

Environment: Browser

The getPage() function allows us to access pageContext in the browser.

// *.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 json-s.