@storyofams/storyblok-toolkit
v1.6.9
Published
Batteries-included toolset for efficient development of React frontends with Storyblok as a headless CMS.
Downloads
157
Keywords
Readme
Purpose
The aim of this library is to make integrating Storyblok in a React frontend easy.
We provide wrappers to abstract away the setup process (implementing the Storyblok JS Bridge, making the app work with the Visual Editor). We also provide an easy way to configure a GraphQL client, an optimized image component and some utility functions.
Installation
yarn add @storyofams/storyblok-toolkit
# or
npm install @storyofams/storyblok-toolkitFeatures
The following API's are included:
withStory()andStoryProvider:withStorywraps a component/page where a story is loaded, and makes sure to keep it in sync with the Visual Editor.StoryProvideris a global provider that provides the context to makewithStorywork.useStory(): alternative towithStory, gets the synced story.getClient(): properly configures agraphql-requestclient to interact with Storyblok's GraphQL API.Image: automatically optimized and responsive images using Storyblok's image service. With LQIP (Low-Quality Image Placeholders) support.getImageProps(): get optimized image sizes without usingImage.getExcerpt(): get an excerpt text from a richtext field.getPlainText(): get plaintext from a richtext field.
Next.js specific:
getStaticPropsWithSdk(): provides a properly configuredgraphql-requestclient, typed usinggraphql-code-generatorto interact with Storyblok's GraphQL API, as a prop inside ofgetStaticProps.nextPreviewHandlers(): API handlers to implement Next.js's preview mode.
