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 a Hero Section

enterprise plans

Sometimes you want to just one section of a page to be visually editable, such as for the hero section of a common page, like a collection page.

Model definition

A standard section model named collection-hero is all you need. Name this section based on what kind of page this section is on, such as if it's on a product collection page. Another example is if this section is on a different page type, such as a product page, you may want to use a more fitting name like product-hero.

By default, you don't need any fields. Instead, use targeting to determine if different visitors or pages should see a different hero.

Example code

// pages/collections/[collection].jsx
import { BuilderComponent, builder } from '@builder.io/react';

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

export async function getStaticProps({ params }) {
  const urlPath = '/' + (params?.page?.join('/') || '');
  
  const hero = await builder
    .get('collection-hero', { 
      userAttributes: { 
        // Here, you can target different hero sections
        // to different URL paths. Optionally, add other properties to target
        urlPath 
      } 
    })
    .toPromise();

  return {
    props: {
      hero: hero || null,
    },
  };
}

export default function Page({ hero }) {
  return (
    <>
      {/* Put your header here. */}
      <YourHeader />
      <BuilderComponent model="collection-hero" content={hero} />
      {/* Put the rest of your page here. */}
      <TheRestOfYourPage />
    </>
  );
}