This repository serves as a starter template for integrating Next.js 15 with StoryBlok. It includes all the necessary configurations to help you get started with a headless CMS and a static site generator built with the App Router.
- Next.js 15 with App Router
- StoryBlok integration
- Pages Revalidation API
- StoryBlok Live-Preview integration
- Static Site Generation
- Tailwind CSS for styling
- TypeScript for type safety
Ensure you have a StoryBlok account and a space with default content. If not, create a free account here.
-
Create a
.env.localfile in the root of the project and add the following environment variable:NEXT_PUBLIC_STORYBLOK_TOKEN=your_storyblok_preview_token
Replace
your_storyblok_preview_tokenwith your actual StoryBlok API preview token. -
Set up a preview domain in your StoryBlok space settings under
Settings > Visual Editor > Location (default environment). Change it to:https://localhost:3000/live-preview/
-
Run the development server:
yarn run dev
Open https://localhost:3000 in your browser and approve the security exception to enable StoryBlok live preview.
-
Ensure your StoryBlok home page content is correct. Remove all sections except Teaser and save it.
-
Click the save button in StoryBlok to see the live preview of your home page.
Create two projects in Vercel: one for preview and one for production. The only difference between them is the environment variable. Ensure the production project uses the READ token and the preview project uses the PREVIEW token to secure your draft content.
We have provided a basic revalidation flow. Create a webhook in StoryBlok under Settings > Webhooks with the following URL:
https://your-project.vercel.app/api/revalidateReplace your-project with your actual Vercel project name.
For a step-by-step setup guide, check our article that will walk you through the entire process.