withCroct
Learn how to enable personalization for Storyblok content.
This function decorates the Storyblok SDK initialization options to enable automatic content personalization.
It intercepts Storyblok API calls and replaces content that references slots with personalized content. In the Storyblok visual editor, personalization is automatically bypassed so editors always see the original content.
Signature
function withCroct(options: SbSDKOptions): SbSDKOptionsExample
Here is an example of how to use this function:
import {storyblokInit, apiPlugin} from '@storyblok/js';import {withCroct} from '@croct/plug-storyblok/js';
storyblokInit(withCroct({ accessToken: 'YOUR_ACCESS_TOKEN', use: [apiPlugin], components: {},}));Parameters
The following list describes the supported parameters:
- optionsSbSDKOptions
The Storyblok SDK initialization options, the same object you would normally pass to storyblokInit.
Return value
Returns the decorated options object with the same type as the input. The returned object can be passed directly to storyblokInit.
Platform imports
The following table lists the import path for each supported platform:
| Platform | Import path |
|---|---|
| JavaScript | @croct/plug-storyblok/js |
| React | @croct/plug-storyblok/react |
| Next.js | @croct/plug-storyblok/next |