Storyblok Raises $80M Series C - Read News

Skip to main content

Announcing @storyblok/react

Arisa Fukuzaki
Try Storyblok

Storyblok is the first headless CMS that works for developers & marketers alike.

Starting from our brand new @storyblok/js, we announced @storyblok/svelte about 1 week and a few days ago.

Today, we'd like to announce another hot🔥 SDK - @storyblok/react 🥳

We reviewed how React & Storyblok projects are handled and took care of the pain points to deliver less complication.

Let us know how's your DX with our new @storyblok/react SDK!

Special thanks to AlexFacundo, and Josefine for their hard & awesome work 🙏

You'll need TL;DR? You can jump directly to the LIVE DEMO in Stackblitz right away.

Section titled Usage

First things first, install @storyblok/react by running the command below.

      npm install @storyblok/react
// yarn add @storyblok/react

Section titled Initialization

The next step, register the plugin on your application and add the access token from your Storyblok space.


i.e. You can do that in pages/_app.js if you use @storyblok/react for your Next.js projects, or in index.js file in React apps.

If you would like to use the Storyblok API Client, you can add apiPlugin.

      import { storyblokInit, apiPlugin } from "@storyblok/react";
import Page from "./components/Page.jsx";
import Teaser from "./components/Teaser.jsx";

  accessToken: "YOUR_ACCESS_TOKEN",
  // bridge: true,
  use: [apiPlugin],
  components: {
    page: Page,
    teaser: Teaser,

Did you realize something?😎

You don't have to handle conditionally returning components by yourself anymore!

We took care of all and you just need to add all your components to the components object in the storyblokInit function, and that's it!

Section titled Query Storyblok API and listen for Visual Editor changes

You can use the convenient useStoryblok(slug, apiOptions) hook to get the story from the Storyblok CDN API, and automatically use Storyblok Bridge to listen for the Visual Editor live changes.

      import { useStoryblok, StoryblokComponent } from "@storyblok/react";

export default Home() {
  const story = useStoryblok("react", { version: "draft" });

  if (!story.content) {
    return <div>Loading...</div>;

  return <StoryblokComponent blok={story.content} />;

Then the <StoryblokComponent blok={blok} you saw before will take care of loading them for you 😉.

Section titled Next.js example:

      import { useStoryblokState, useStoryblokApi, StoryblokComponent } from "@storyblok/react";

export default function Home({ story: initialStory }) {
  const story = useStoryblokState(initialStory);

  if (!story.content) {
    return <div>Loading...</div>;

  return <StoryblokComponent blok={story.content} />;

export async function getStaticProps({ preview = false }) {
  const storyblokApi = useStoryblokApi()
  let { data } = await storyblokApi.get(`cdn/stories/react`, {
    version: "draft"

  return {
    props: {
      story: data ? data.story : false,
    revalidate: 3600, // revalidate every hour
@storyblok/react docs
Storyblok Learning Hub announcement blog post