Building Sitecore Headless Sites With Next.js and the Content SDK

Next.js is the default frontend for modern Sitecore

Modern Sitecore development is headless: Sitecore manages content and layout, and a Next.js app renders it. Sitecore JSS has been the foundation for years, and Sitecore has introduced a leaner Content SDK for XM Cloud projects. Check the official docs for which SDK is recommended for your version.

The Architecture

Content authors → XM Cloud → Experience Edge (GraphQL CDN) → Next.js app → Visitors
  • Layout Service returns the page structure: placeholders and components with their fields
  • Next.js maps each component name to a React component and renders it

Component Mapping

// components/Hero.tsx
import { Text, Image, Field, ImageField } from '@sitecore-content-sdk/nextjs';

type HeroProps = {
  fields: { title: Field<string>; image: ImageField };
};

export const Default = ({ fields }: HeroProps) => (
  <section className="hero">
    <Image field={fields.image} />
    <Text tag="h1" field={fields.title} />
  </section>
);

The SDK's field components handle editing in Pages automatically — the same component is editable in the editor and fast in production. Package names differ between JSS and the Content SDK; follow the starter for your setup.

Data Fetching

  • SSG with ISR for most marketing pages — fast and cacheable
  • SSR for personalised or frequently changing pages
  • GraphQL queries to Experience Edge for lists, search, and related content

Local Development

Start from the official XM Cloud starter. Connect your local Next.js app to an XM Cloud environment (or local containers) and use the editing host for Pages.

Deployment

  • Deploy the rendering host to Vercel, Netlify, or another Node host
  • XM Cloud Deploy builds and deploys the CM side
  • Configure publish webhooks to trigger revalidation

Tips

  • Keep components presentation-focused; move data logic to hooks or services
  • Use TypeScript types for every component's fields
  • Watch bundle size — headless sites should be fast
  • Monitor Core Web Vitals in production

Headless Sitecore is just a very well-structured Next.js app. Strong React skills transfer directly.

Arivanandhan Chitheshwaran