> ## Documentation Index
> Fetch the complete documentation index at: https://docs.makeswift.com/llms.txt
> Use this file to discover all available pages before exploring further.

# getPageSnapshot

> An instance method of the Makeswift [client](/developer/reference/client/constructor) that fetches a snapshot of a Makeswift page at a given path. This snapshot is only intended to be rendered by the `<Page>` component.

## Arguments

1. <ParamField query="pathname" type="string" required>
     The path of the page.
   </ParamField>
2. <ParamField query="options" type="object" required>
     Options for site version and locale.

     <Expandable>
       <ParamField query="siteVersion" type="SiteVersion" required>
         For **App Router**, this is the return value from calling
         [getSiteVersion](/developer/reference/get-site-version). For **Pages
         Router**, this is the return value from
         [Makeswift.getSiteVersion](/developer/reference/client/get-site-version).
       </ParamField>

       <ParamField query="locale" type="string">
         A valid locale string (ex. `"en-US"`).
       </ParamField>

       <ParamField query="allowLocaleFallback" type="boolean" default={true}>
         Controls whether a request for a localized page should fallback to the default locale if the requested locale is not available.
       </ParamField>
     </Expandable>
   </ParamField>

## Return type

<ResponseField name="snapshot" type="Promise<MakeswiftPageSnapshot | null>">
  An opaque `Snapshot` object that is only intended to be rendered by the
  [`<Page>`](/developer/reference/components/page) component.
</ResponseField>

## Examples

### Basic usage

The following example sets up a [catch all route](https://nextjs.org/docs/pages/building-your-application/routing/dynamic-routes#catch-all-segments) where page snapshots are fetched from Makeswift and rendered using the [`<Page>`](/developer/reference/components/page) component.

<CodeGroup>
  ```tsx src/pages/[[...path]].tsx theme={null}
  import {
    GetStaticPathsResult,
    GetStaticPropsContext,
    GetStaticPropsResult,
  } from "next";

  import {
    Page as MakeswiftPage,
    PageProps as MakeswiftPageProps,
    Makeswift,
    type SiteVersion
  } from "@makeswift/runtime/next";

  import { client } from "@/makeswift/client";
  import "@/makeswift/components";

  type ParsedUrlQuery = { path?: string[] };

  export async function getStaticPaths(): Promise<
    GetStaticPathsResult<ParsedUrlQuery>
  > {
    const pages = await client.getPages().toArray();

    return {
      paths: pages.map((page) => ({
        params: {
          path: page.path.split("/").filter((segment) => segment !== ""),
        },
      })),
      fallback: "blocking",
    };
  }

  export type PageProps = MakeswiftPageProps & {
    siteVersion: SiteVersion | null;
  };

  export async function getStaticProps({
    params,
    previewData,
  }: GetStaticPropsContext<ParsedUrlQuery>): Promise<
    GetStaticPropsResult<PageProps>
  > {
    const path = "/" + (params?.path ?? []).join("/");
    const siteVersion = Makeswift.getSiteVersion(previewData);
    const snapshot = await client.getPageSnapshot(path, {
      siteVersion,
    });

    if (snapshot == null) return { notFound: true };

    return {
      props: {
        snapshot,
        siteVersion,
      },
    };
  }

  export default function Page({ snapshot }: MakeswiftPageProps) {
    return <MakeswiftPage snapshot={snapshot} />;
  }
  ```
</CodeGroup>

### Localization

The following example uses the `locale` param in `getStaticProps` to fetch a localized snapshot of a page.

```tsx src/pages/[[...path]].tsx {35, 41, 48, 57} theme={null}
import {
  GetStaticPathsResult,
  GetStaticPropsContext,
  GetStaticPropsResult,
} from "next";

import {
  Page as MakeswiftPage,
  PageProps as MakeswiftPageProps,
  Makeswift,
  type SiteVersion
} from "@makeswift/runtime/next";

import { client } from "@/makeswift/client";
import "@/makeswift/components";

type ParsedUrlQuery = { path?: string[] };

export async function getStaticPaths(): Promise<
  GetStaticPathsResult<ParsedUrlQuery>
> {
  const pages = await client.getPages().toArray();

  return {
    paths: pages.map((page) => ({
      params: {
        path: page.path.split("/").filter((segment) => segment !== ""),
      },
    })),
    fallback: "blocking",
  };
}

export type PageProps = MakeswiftPageProps & {
  siteVersion: SiteVersion | null;
  locale: string | undefined;
};

export async function getStaticProps({
  params,
  previewData,
  locale,
}: GetStaticPropsContext<ParsedUrlQuery>): Promise<
  GetStaticPropsResult<PageProps>
> {
  const path = "/" + (params?.path ?? []).join("/");
  const siteVersion = Makeswift.getSiteVersion(previewData);
  const snapshot = await client.getPageSnapshot(path, {
    siteVersion,
    locale,
  });

  if (snapshot == null) return { notFound: true };

  return {
    props: {
      snapshot,
      siteVersion,
      locale,
    },
  };
}

export default function Page({ snapshot }: MakeswiftPageProps) {
  return <MakeswiftPage snapshot={snapshot} />;
}
```

## Changelog

| Version                                                                                          | Changes                             |
| ------------------------------------------------------------------------------------------------ | ----------------------------------- |
| [`v0.24.0`](https://github.com/makeswift/makeswift/releases/tag/%40makeswift%2Fruntime%400.24.0) | Adds `allowLocaleFallback` option   |
| [`v0.11.0`](https://github.com/makeswift/makeswift/releases/tag/%40makeswift%2Fruntime%400.11.0) | Adds `locale` option                |
| [`v0.2.0`](https://github.com/makeswift/makeswift/releases/tag/%40makeswift%2Fruntime%400.2.0)   | `getPageSnapshot` method introduced |
