Installation guide for Sitecore headless with Next.js using SSG

Step-by-step guidance for implementing Sitecore Headless with Next.js using static site generation.

June 8, 2025 | 3.5 mins read

oi-image4.webp
Tejas Thorat
Tejas Thorat
Senior Software Engineer

Sitecore Developer & Team Lead, Sitecore DXP & SXA Specialist, Coveo Search, Azure Cloud, Iubenda Compliance Consultant, Git & Cloudflare, Delivering Scalable Digital.

Download and Install Sitecore Headless Rendering

  • Download the Sitecore Headless Rendering Package from the Sitecore Headless Rendering | Downloads | Sitecore Developer Portal according to your Sitecore version.

  • Log in to Sitecore.

  • Upload and install the package.

Create a Headless Tenant and Site

  • Right-click on Content, click Insert, and select Headless Tenant.

Installation Guide for Sitecore Headless with Next.js Using SSG

hmac=d4f579dca088b55292aef6df7f0358aac80e6a6fecfa401481cf11e31d1861ce" alt="headless tenant" width="500" height="218">

  • Give it a name (e.g., HeadlessTenant).

  • Right-click on the Tenant , click Insert , and select Headless Site.

Sitecore Headless with Next.js Using SSG

  • Give it a name (e.g., HeadlessSite).

Create a JSS API Key

  • Navigate to /sitecore /system /Settings /Services /API Keys.

  • Right-click on API Keys, click Insert, and select API Key.

Installation Guide for Sitecore Headless with Next.js Using SSG

  • Name it (e.g., HeadlessAPI).

  • Update the CORS Origins and Allowed Controllers value to * or your domain

Create a Next.js Application

  • Create an empty folder and open it with VS Code.

  • Open the PowerShell terminal.

  • Run the following command to install JSS CLI:

npm install -g @sitecore-jss/sitecore-jss-cli
  • Run the following command to create a Next.js app:

npx create-sitecore-jss --templates nextjs, nextjs-sxa
--appName headless-nextjs-app --hostName
headless.dev.local --fetchWith GraphQL

Follow the prompts:

  • Where would you like your new app created?: Press Enter to use the default path.

  • How would you like to prerender your application?: Select SSG.

  • Are you building for Sitecore XM Cloud?: Select No.

  • If you encounter errors, check your Node.js version (e.g., use 22.13.1).

Setup Host Entry in IIS

  • Open IIS.

  • Select your site and click Bindings.

Installation Guide for Sitecore Headless with Next.js Using SSG

Configure Next.js App with Sitecore

  • Navigate to your Next.js app folder in the terminal..

  • Run the following command:

jss setup

Answer the prompts:

  • Is your Sitecore instance on this machine or accessible via a network share?: y

  • Path to the Sitecore folder: Enter your Sitecore instance path.

  • Sitecore hostname: http://your-hostname

  • Sitecore import service URL: Leave blank.

  • Sitecore API Key: Copy the API Key GUID from /sitecore /system /Settings /Services /API Keys /Your API Key.

  • Deployment Secret: Press Enterto generate a secret key.

  • Open scjssconfig.json, copy the deploySecret value.

Installation Guide for Sitecore Headless with Next.js Using SSG

  • Open .env, find the variable JSS_EDITING_SECRET, and paste the value.

Additional Configuration

  • Open YourAppName.config, remove or comment out the site patch.

  • Open dictionary-service-factory.ts, paste your Home item GUID from Sitecore in the rootItemId field.

Update the Site Grouping:

  • Navigate to Site Grouping under Site Settings.

  • Find your Site and update the Site name label.

Installation Guide for Sitecore Headless with Next.js Using SSG

Configure Rendering Hosts

  • Navigate to /sitecore /system /Settings /Services /Rendering Hosts /Default.

    Update the Server-Side Rendering Engine Endpoint URL:

    http://localhost:3000 /api /editing /render

Installation Guide for Sitecore Headless with Next.js Using SSG

  • Update the Application Name.

Deploy and Start the Application

  • In VS Code, run:

jss deploy config
jss start:connected
  • In Sitecore, navigate to Home item and open it with Experience Editor

Installation Guide for Sitecore Headless with Next.js Using SSG

Installation Guide for Sitecore Headless with Next.js Using SSG

Congratulations! You have successfully set up Sitecore JSS with Next.js using SSG.

Setting up Sitecore JSS with Next.js using Static Site Generation (SSG) may seem complex at first, but by following a structured step-by-step approach, you can have a fully functional headless application integrated with Sitecore. From installing Sitecore Headless Rendering and creating your tenant and site, to configuring the API key, setting up the Next.js application, and finalizing the deployment—each step builds a solid foundation for a performant, scalable, and modern web experience.With this setup, you now have the flexibility to develop components using React, manage content via Sitecore’s Experience Editor, and leverage the benefits of static site generation for improved speed and SEO. Happy coding!

Let’s Discuss Your Digital Experience Goals

Contact-Form

Thank You!

Thanks for your interest in Techxot! Our team will contact you soon. We look forward to helping you reach your goals.