Skip to main content

Documentation Index

Fetch the complete documentation index at: https://makeswift-sasha-eng-8460-create-a-guide-for-troubleshooting.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

Arguments

  1. id
    string
    required
    The id of the component.
  2. options
    object
    required
    Options for site version and locale.

Return type

snapshot
Promise<MakeswiftComponentSnapshot | null>
An opaque MakeswiftComponentSnapshot object that is only intended to be rendered by <MakeswiftComponent> and <Slot>.

Examples

The following examples expect that you have a Makeswift client instance already configured and exported from "@/makeswift/client.ts". If you don’t, see the client reference.

Basic usage

import { getSiteVersion } from "@makeswift/runtime/next/server";
import { Makeswift } from "@makeswift/runtime/next";
import { ReactRuntime } from "@makeswift/runtime/react";

export const runtime = new ReactRuntime();

export const client = new Makeswift(process.env.MAKESWIFT_SITE_API_KEY, {
  runtime,
});

const productDetailSnapshot = await client.getComponentSnapshot(
  `my-product-details`,
  {
    siteVersion: getSiteVersion(),
  }
);

Localization

import { getSiteVersion } from "@makeswift/runtime/next/server";
import { Makeswift } from "@makeswift/runtime/next";
import { ReactRuntime } from "@makeswift/runtime/react";

export const runtime = new ReactRuntime();

export const client = new Makeswift(process.env.MAKESWIFT_SITE_API_KEY, {
  runtime,
});

const locale = "en-US";
const snapshot = await client.getComponentSnapshot(id, {
  siteVersion: getSiteVersion(),
  locale,
});

Changelog

VersionChanges
v0.23.0getComponentSnapshot method introduced