Skip to content
CONTACT SALESSTART BUILDING
Landing pages
Blog Article
Hero Section
Navigation Links
Announcement Bar
Product Details
Product Editorial
Homepage
Request a blueprintGo to developer docs

Integrate Product Details

It can be helpful to keep product details in a CMS like Builder, in place of or in complement to an e-commerce platform.

In this way, you can do things such as extend your product info with additional rich content, localize product info, use A/B testing, set up scheduling, and configure targeting.

Model definition

First, create a structured data model named product-detailswith some fields:

nametypenotes

name

text

Product Name

description

html

Rich text for your product detailed description

images

list

List with subfields:

nametype

image

file

alt

text

handle

text

A unique URL handle for this product; for example, my-product to display at /products/my-product

collection

reference

Reference to a collection, either to your backend via an e-commerce plugin or to another data model in Builder that represents your product collections

You can create as many additional fields as you like for additional product info.

Example Code

Below is an example in pages/products/[product].jsx:

import { builder } from '@builder.io/react';

// Replace with your Public API Key.
builder.init(YOUR_API_KEY);

export async function getStaticProps({ params }) {
  const productDetails = await builder.get('product-details', {
     query: { 
       // Query product details by its handle field
       'data.handle': params.product
     }
  }).promise();

  return {
    props: {
      productDetails: productDetails || null,
    },
    // Show a 404 page if no product is found
    notFound: !productDetails,
    revalidate: 5,
  };
}

export default function Home({ productDetails }) {
  return (
    <>
      <YourHeader />
      <ProductDetails product={productDetails} />
    </>
  );
}