Skip to main contentWhere does your team stand on AI adoption?
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 Announcement Bars

Enterprise plans

An announcement bar at the top of your site is a common pattern in Builder.

Model definition

A standard section model named announcement-bar is all you need. By default, you don't need any fields. Instead, use targeting to decide which announcement bar shows where.

Example Code

// pages/[...page].tsx import React from "react"; import { BuilderComponent, builder } from "@builder.io/react"; import { GetStaticProps } from "next"; // TO DO: Add your Public API Key builder.init('YOUR_API_KEY'); export const getStaticProps: GetStaticProps = async ({ params }) => { const urlPath = '/' + (Array.isArray(params?.page) ? params.page.join('/') : params?.page || ''); // Fetch the content for the specific section using its model name const announce = await builder .get("announcement-bar", { userAttributes: { urlPath, }, }) .toPromise(); return { props: { announce: announce || null, }, }; }; export default function Page({ announce }) { return ( <> {announce && ( <BuilderComponent model="announcement-bar" content={announce} /> )} <RestOfYourPage /> </> ); }

For more detail on creating an Announcement Bar in Builder, refer to Integrating Sections.