
Language 🇺🇸 English
Storyblok Installation
Storyblok Next Steps
Add Live Commenting to Sites Built with Storyblok
This guide adds the FastComments live commenting widget to a website or app whose content is stored in Storyblok.
Storyblok is a headless CMS and does not render the public site. The widget is added to the frontend that fetches stories from the Content Delivery API and renders them, and each comment thread is tied to the story's UUID rather than to its slug or URL. Storyblok's own comments, opened from the comment button on each field in the Visual Editor, are discussions between members of the space about a story's content. They are not shown to visitors of the site.
This tutorial requires a FastComments account. You can create an account here.
Get the Story UUID 
The Content Delivery API returns two identifiers for each story:
uuid: the unique identifier of the story in the space, for examplea3b5c7d9-1234-4f56-8a90-bcdef1234567.id: the legacy numeric story ID. Storyblok keeps it in API responses for existing integrations and recommendsuuidfor new projects.
Use the story's uuid as the FastComments urlId. A story's full_slug includes the path of its parent folder, so it changes when an editor edits the slug or moves the story to another folder. The uuid does not depend on the slug or the folder, so the comment thread stays attached to the story when its URL changes.
Storyblok's current Next.js setup uses the @storyblok/api-client package for the Content Delivery API and @storyblok/react to render blocks:

The API client is created in src/lib/storyblok.js, as in Storyblok's Next.js guide:

apiClient.stories.get takes a story's full slug, numeric ID, or UUID, and returns an object with data and error properties. The story is in data.story, and its UUID is data.story.uuid:

version: 'published' returns the published version of the story. Requesting version: 'draft' requires a preview access token.
Projects that use the older storyblok-js-client package get the same story object from storyblok.get('cdn/stories/blog/my-first-post', { version: 'published' }), in data.story.
Add the Widget in Next.js 
This example uses the Next.js App Router and the FastComments Next.js library, fastcomments-nextjs, which supports Next.js 13 to 16 with React 18 or 19.

The page below is a server component for the route /blog/[slug]. It assumes the blog posts are stories in a folder with the slug blog, so the full slug of a post is blog/<slug>. It renders the story content with StoryblokBlock and then the comment widget, with the story UUID as the urlId:

If you are logged in to FastComments, the snippet above contains your tenant ID. Otherwise, replace demo with your tenant ID.
Notes on the example:
- The
FastCommentscomponent declares'use client'itself, so it can be rendered from a server component without a wrapper. - The Storyblok API client runs only on the server in this page, so the access token is not sent to the browser and
STORYBLOK_DELIVERY_API_TOKENdoes not need theNEXT_PUBLIC_prefix. - The
keyprop makes React mount a new widget when the reader navigates from one story to another. paramsis a promise in Next.js 15 and later. In Next.js 13 and 14 it is a plain object, andawaiton it returns the same object.- For accounts in the EU region, add
region="eu"to theFastCommentscomponent. This setting is independent of the region of the Storyblok space.
The comment widget uses the current page URL as the link for notification emails and the moderation page. To link comments to a different URL, pass a url prop. See How Comments are Tied to Pages and Articles.
For React applications that do not use Next.js, the React library provides the FastCommentsCommentWidget component, which takes the same tenantId and urlId props.
To let editors choose which stories have comments and where the widget appears in the story, render the widget from a block instead, as described in Add a FastComments Block for Editors.
Add a FastComments Block for Editors 
Instead of rendering the widget on every story of a route, the frontend can render it from a block. Editors add the block to the stories that should have comments, at the position where the comments should appear. This replaces the FastComments component in the page from Add the Widget in Next.js.
Create the Block in Storyblok
- In your Storyblok space, open the Block Library and select + New Block.
- Choose the Nestable block type.
- Enter
fastcommentsas the technical name. The block needs no fields.
Editors can then add the block to a story's blocks field, such as the body field of the page content type, in the Visual Editor. In the API response, the block appears in the field with component: 'fastcomments'.
Render the Block in the Frontend
A block component receives the block data, which does not include the story UUID. StoryblokBlock passes any props other than block to the registered component, so the page passes the story UUID down as a storyUuid prop.
Create the component for the block:

If you are logged in to FastComments, the snippet above contains your tenant ID. Otherwise, replace demo with your tenant ID.
Register it in src/lib/storyblok.js. The key must match the block's technical name:

Pass storyUuid from the page component to the blocks in its body field:

In the route, pass the story UUID to the top-level StoryblokBlock, and remove the FastComments component and its import:

The page component in Storyblok's Next.js guide already renders a <main> element, so the route returns StoryblokBlock without a wrapper.
If the FastComments block is placed inside another block, such as a grid, that block's component must also pass storyUuid to its nested StoryblokBlock elements. Otherwise the FastComments block receives no UUID and renders nothing.
The Visual Editor Preview 
The Visual Editor loads the frontend's preview URL, set under Settings > Visual Editor, in an iframe. Storyblok requires the preview to be served over HTTPS. The FastComments widget runs in that page like on the public site, so it is subject to the same domain check.
There are two ways to handle the widget in the Visual Editor.
Show the Widget in the Visual Editor
Add the domain of the preview URL to the domain configuration page of your FastComments account. The widget in the preview loads the same thread as the public page, because the urlId is the story UUID in both places. Comments posted from the preview are real comments on that thread.
Hide the Widget in the Visual Editor
The Visual Editor appends query parameters to the preview URL, including _storyblok, which contains the numeric ID of the story being edited. The frontend can check for this parameter and skip the widget. In the route from Add a FastComments Block for Editors, leaving out storyUuid makes the block render nothing:

Reading searchParams makes Next.js render the page at request time instead of at build time. If the preview runs as a separate deployment, an environment variable set only on that deployment can be checked instead, which keeps the public pages static.
This example only shows the comment handling. Loading draft content and live updates in the Visual Editor are covered in Storyblok's Next.js visual preview guide.
Add the Widget Without a Framework Library 
Frontends that render HTML from a template, or that do not use a FastComments framework library, can load the widget with the FastComments VanillaJS script. The template writes the story's uuid into a data-story-uuid attribute on the widget container, and the script passes it to the widget as the urlId.
Add the following to the template that renders a story, at the position where the comments should appear. Replace STORY_UUID with the template expression that outputs the story's uuid.

If you are logged in to FastComments, the snippet above contains your tenant ID. Otherwise, replace demo with your tenant ID.
For accounts in the EU region, load the script from https://cdn-eu.fastcomments.com/js/embed-v2.min.js and add region: 'eu' to the configuration object.
In a single-page application that fetches stories in the browser, pass story.uuid to urlId directly instead of reading it from an attribute. @storyblok/api-client supports current versions of Chrome, Edge, Firefox, and Safari.
FastComments also has libraries for other frontend frameworks. Each of them accepts a urlId option that takes the story UUID in the same way:
Domain Errors 
The widget may show an authorization error like the following:
This error means the domain of the page is not in the list of domains allowed for your FastComments account.
Add the domain of the frontend that renders your Storyblok stories on the domain configuration page of your account. If the site is also served from other domains, such as staging deployments or the preview URL used by the Visual Editor, add those domains as well, or hide the widget on them as described in The Visual Editor Preview.
Customization 
Styling and configuration options for the widget are described in the Customization Documentation.
With the Next.js library, configuration options are passed as props of the FastComments component. With the VanillaJS script, they are added to the object passed to window.FastCommentsUI. Many options can also be changed without code on the widget customization page of your FastComments account.
Options can also come from the FastComments block. For example, a Boolean field added to the fastcomments block in the Block Library is available on the block prop of FastCommentsBlock and can be passed to the widget, such as readonly={block.readonly} for a field with the technical name readonly. See Prevent New Replies & Disable Votes.
To show signed-in users of your site as the comment authors, use FastComments Secure SSO. The SSO verification hash is an HMAC-SHA256 hash computed with your FastComments API secret, so it must be generated in server-side code, such as a Next.js server component, and passed to the widget. Do not compute it in browser JavaScript or include the API secret in client-side code.