Letting built-in Plasmic data integration be pre-fetched using Next.js SSR (codegen approach)

Hi @stijn_de-vos ,

Thanks for providing the details. The data is prefetched by default. To access the value in the codegen mode, please visit the following docs for more details

An example code snippet is provided below:

import { extractPlasmicQueryData } from '@plasmicapp/react-web/lib/prepass';
import { PlasmicQueryDataProvider } from '@plasmicapp/react-web/lib/query';

// Pre-fetching
export function getStaticProps() {
  const queryCache = await extractPlasmicQueryData(<PlasmicHome />);
  return {
    props: { queryCache }
  };
}

// Rendering page
export function HomePage({ queryCache }) {
  return (
    <PlasmicQueryDataProvider prefetchedCache={queryCache}>
      <PlasmicHome />
    </PlasmicQueryDataProvider>
  );
}
1 Like