A statically generated blog example using Next.js and Sitecore Experience Edge (Edge for Content Hub).
This example showcases Next.js's Static Generation feature using Sitecore Experience Edge for Content Hub as the data source.
nextjs-sitecore-blog.vercel.app
To use this project, you need to have your Sitecore Content Hub sandbox up and running with content publishing enabled.
This project uses the content schema and content entities provided with the Lighthouse Template.
For more information: https://docs.stylelabs.com/contenthub/4.1.x/content/user-documentation/experience-edge/content-delivery/prerequisites.html
First, Follow The Quickstart Guide to create a content collection and publish the content collection.
The Delivery Platform provides 2 GraphQL APIs:
- Preview API exposing a preview of the content. Optimized for live access of the latest data.
- Delivery API exposes your published content with an identical structure to the Preview API. It is optimized for performance and high availability.
To create an authentication key for the Delivery API:
- On the main menu bar, click Content and select Content collections.
- On the Content collections page, select the content collection for which you want to create an API key.
- On the Collection detail page, on the upper right, click More actions dots icon and then select API keys icon API keys.
- In the API keys dialog box, click + API key.
- In the API keys dialog box, enter a name for the key and select Preview then click Create.
- Copy and save for future use the generated token which represents your API key.
- Repeat Step 5 and 6 for the delivery API Key.
You can deploy this app to the cloud with Vercel (Documentation). Use the Deploy Button in this section Deploy your own
Or if you need to work locally and make some changes, go to Manual Setup
Using the Deploy Button below, you'll deploy the Next.js project as well as connect it to your Sitecore Content Hub sandbox using Vercel.
Copy the .env.local.example
file in this directory to .env.local
(which will be ignored by Git):
cp .env.local.example .env.local
Then set each variable on .env.local
:
SITECORE_CONTENTHUB_PUBLIC_URL
should be the Content Hub Instance UrlSITECORE_CONTENTHUB_EDGE_DELIVERY_ENDPOINT
should be https://edge-beta.sitecorecloud.io/api/graphql/v1SITECORE_CONTENTHUB_PREVIEW_ACCESS_TOKEN
should be the Preview API KeySITECORE_CONTENTHUB_DELIVERY_ACCESS_TOKEN
should be the Delivery API KeySITECORE_CONTENTHUB_CONTENTCOLLECTION_NAME
should be the collection name createdas source for this blog example.
Your .env.local
file should look like this:
SITECORE_CONTENTHUB_PUBLIC_URL=https://[your-sandbox-name].stylelabs.io
SITECORE_CONTENTHUB_EDGE_DELIVERY_ENDPOINT=https://edge-beta.sitecorecloud.io/api/graphql/v1
SITECORE_CONTENTHUB_PREVIEW_ACCESS_TOKEN=...
SITECORE_CONTENTHUB_DELIVERY_ACCESS_TOKEN=...
SITECORE_CONTENTHUB_CONTENTCOLLECTION_NAME=Lighthouse Blog
Run Next.js in development mode
npm install
npm run dev
# or
yarn install
yarn dev
Your blog should be up and running on http://localhost:3000! If it doesn't work, post on GitHub discussions.
To deploy your local project to Vercel, push it to GitHub/GitLab/Bitbucket and import to Vercel.
Important: When you import your project on Vercel, make sure to click on Environment Variables and set them to match your .env.local
file.
- WordPress
- DatoCMS
- Sanity
- TakeShape
- Prismic
- Strapi
- Agility CMS
- Cosmic
- ButterCMS
- Storyblok
- GraphCMS
- Kontent
- Ghost
- Blog Starter
Execute create-next-app
with npm or Yarn to bootstrap the example:
npx create-next-app --example cms-sitecore cms-sitecore-app
# or
yarn create next-app --example cms-sitecore cms-sitecore-app