Announcing gatsby-source-storyblok V4
Storyblok is the first headless CMS that works for developers & marketers alike.
We'd like to announce gatsby-source-storyblok V4 has been released to improve your Storyblok x Gatsby DX🥳
We reviewed how Gatsby & Storyblok projects are handled differently from our @storyblok/react SDK and took care of the pain points to deliver less complication.
Let us know how's your DX with our gatsby-source-storyblok V4 SDK!
Special thanks to Alex for his hard & awesome collaboration work 🙏
You'll need TL;DR? You can jump directly to the LIVE DEMO in CodeSandbox right away.
Usage
First things first, install gatsby-source-storyblok by running the command below.
Initialization
Next step, register the plugin on your application and add the access token from your Storyblok space.
i.e. You can initialize just once in components/layout.jsx if you use gatsby-source-storyblok for your Gatsby projects.
If you would like to use the Storyblok API Client, you can add apiPlugin
.
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!
Query Storyblok API and listen for Visual Editor changes
You can use the convenient useStoryblokState(originalStory, bridgeOptions)
hook to get the story from the Storyblok CDN API, and automatically use Storyblok Bridge to listen for the Visual Editor live changes.
Link your components to Storyblok Visual Editor
For every React component, you want to link to its corresponding Storyblok component, you can use storyblokEditable
function with the blok content where blok
is the actual blok data coming from Storyblok's Content Delivery API
Then the <StoryblokComponent blok={blok} />
will take care of loading them for you 😉.
Example:
TL;DR: Play with the Gatsby demo
Next Steps
Want to contribute? You can create an issue or PR on the Gatsby SDK repo or get in touch.
Resource | Link |
---|---|
gatsby-source-storyblok docs | https://www.npmjs.com/package/@storyblok/react |
Storyblok Learning Hub | https://www.storyblok.com/docs |
DEV.to announcement blog post | https://dev.to/storyblok/announcing-gatsby-source-storyblok-v4 |