Skip to content

Starter Template for Next.js, Storyblok and tailwindcss 3

Notifications You must be signed in to change notification settings

snwmilap/next-storyblok

 
 

Repository files navigation

Next.js Storyblok Boilerplate

This repository is a Next.js Storyblok starter template.

Requirements

To use this project you have to have a Storyblok account. If you don't have one yet you can register at Storyblok, it's free.

How to get started?

Read the Next.js 13 tutorial about connecting Storyblok and Next.js

1. Clone the repo

  $ git clone https://github.com/sahli-interactive/next-storyblok.git

2. Install all dependencies

$  yarn # or npm install

3. Adding the Access token

Create a new empty space and copy the Preview Token. Create your .env.local from .env.example:

$ mv .env.example .env.local

Add the token from Storyblok and a password/any string for the preview-mode (and the webhook):

STORYBLOK_TOKEN=<your-new-token>
SECRET=<your-token-or-password>

4. Run your project

Set the preview domain in Storyblok to http:https://localhost:3000/

# to run in developer mode
$ yarn dev # or npm run dev
# to build your project
$ yarn build # or npm run build

5. Setup preview mode

To enable preview mode you have to add two preview URLs in Storyblok:

Preview https://<my-url>/api/draft?secret=<your-preview-password-or-token>&slug=

Exit Preview https://<my-url>/api/exit-draft?slug=

Don't forget to add the secret as env-variable. It might be helpful for the end user to set the preview URL as default.

6. Webhook for revalidation

To revalidate pages after publishing in Storyblok, you have to set up the following Webhook URL: https://<my-url>/api/story-published?secret=<your-preview-paswsword-or-token>

Don't forger to add the secret token as env-variable.

7. Update Storyblok TypeScript types

First, make sure you have the Storyblok CLI installed and set up with your account. Second, replace [SPACE_ID] in your package.json with your space ID e.g. 123456.

Whenever your component definitions have changes, you can update your types:

# get current component definition
$ yarn pull-components
# generate types from component definition
$ yarn generate-sb-types

Resources

About

Starter Template for Next.js, Storyblok and tailwindcss 3

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 80.2%
  • JavaScript 18.9%
  • Other 0.9%