> This page is for Developer.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.makeswift.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.makeswift.com/_mcp/server.

# getPageSnapshot

> An instance method of the Makeswift [client](/developer/docs/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.

An instance method of the Makeswift [client](/developer/docs/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

**`pathname`** `string` — required

The path of the page.

---

**`options`** `object` — required

Options for site version and locale.

#### properties

**`siteVersion`** `SiteVersion` — required

For **App Router**, this is the return value from calling
[getSiteVersion](/developer/docs/reference/functions/get-site-version). For **Pages
Router**, this is the return value from
[Makeswift.getSiteVersion](/developer/docs/reference/client/get-site-version).

---

**`locale`** `string`

A valid locale string (ex. `"en-US"`).

---

**`allowLocaleFallback`** `boolean`

Controls whether a request for a localized page should fallback to the default locale if the requested locale is not available.

---

---

## Return type

**`snapshot`** `Promise<MakeswiftPageSnapshot | null>`

An opaque `Snapshot` object that is only intended to be rendered by the
[`<Page>`](/developer/docs/reference/components/page) component.

---

## 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/docs/reference/components/page) component.

**`src/pages/[[...path]].tsx`**

```tsx src/pages/[[...path]].tsx
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} />;
}
```

### Localization

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

**`src/pages/[[...path]].tsx`**

```tsx src/pages/[[...path]].tsx {35, 41, 48, 57}
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 |