This function can only be called inside of a React Server Component or Route Handler.

Arguments

This function doesn’t take any arguments.

Example

The following example calls getPageSnapshot to query a page snapshot for the root route and passes the return value from getSiteVersion in its configuration options. It then renders the page using the Page component.

import { Page } from "@makeswift/runtime/next";
import { client } from "@/makeswift/client";
import { getSiteVersion } from "@makeswift/runtime/next/server";

export default function Page() {
  const snapshot = await client.getPageSnapshot("/", {
    siteVersion: getSiteVersion(),
  });

  if (snapshot == null) notFound();

  return <Page snapshot={snapshot} />;
}

For a more detailed walkthrough, refer to the App Router Installation guide.