Documentation Index Fetch the complete documentation index at: https://makeswift-openapi-sync-cosmos-pr-2639.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Arguments
Options for site version and locale. Controls whether a request for a localized component should fallback to
the default locale if the requested locale is not available.
Return type
snapshot
Promise<MakeswiftComponentSnapshot | null>
Examples
Basic usage
The following example shows how to fetch a page-specific component snapshot and render it using the <Slot> component within a page.
src/app/products/[slug]/page.tsx
import { getSiteVersion } from "@makeswift/runtime/next/server" ;
import { Slot } from "@makeswift/runtime/next" ;
import { client } from "@/makeswift/client" ;
type Props = {
params : Promise <{ slug : string }>;
};
export default async function ProductPage ({ params } : Props ) {
const { slug } = await params ;
const snapshot = await client . getComponentSnapshot (
`product-details- ${ slug } ` ,
{
siteVersion: getSiteVersion (),
}
);
return (
< main >
< h1 > Product: { slug } </ h1 >
< Slot snapshot = { snapshot } label = { `Product details for ${ slug } ` } />
</ main >
);
}
Localization
The following example uses the locale param to fetch a localized snapshot of a page-specific component.
src/app/[locale]/products/[slug]/page.tsx
import { getSiteVersion } from "@makeswift/runtime/next/server" ;
import { Slot } from "@makeswift/runtime/next" ;
import { client } from "@/makeswift/client" ;
type Props = {
params : Promise <{ locale : string ; slug : string }>;
};
export default async function ProductPage ({ params } : Props ) {
const { locale , slug } = await params ;
const snapshot = await client . getComponentSnapshot (
`product-details- ${ slug } ` ,
{
siteVersion: getSiteVersion (),
locale ,
}
);
return (
< main >
< h1 > Product: { slug } </ h1 >
< Slot snapshot = { snapshot } label = { `Product details for ${ slug } ` } />
</ main >
);
}
Changelog
Version Changes v0.23.0getComponentSnapshot method introduced