How to view a release in a preview environment
With the Releases app, you can schedule stories in releases and schedule your stories for publishing automatically.
This feature is quite useful when you are done with a content pipeline and want to schedule publishing for a date in the future. To enable releases in your Storyblok space, check out our documentation on the Releases app here (opens in a new window) .
Here’s a JavaScript example showing how to add a preview for your releases
- First, navigate to your preview story in the visual editor, and check for the presence of a
_storyblok_release
URL parameter. The URL parameter is attached to the iframesrc
when you’re inside a release.
You can also see this if you can open the story you’re viewing in a release as a preview. Here you can see the full URL with the _storyblok_release
parameter present as shown in the image below
)
- The
_storyblok_release
URL parameter can be used as the value for the from_release API parameter, which is used to fetch this releases version of the story
Here’s a JavaScript code example showing how to do this using the storyblok-js-client (opens in a new window)
import StoryblokClient from 'storyblok-js-client'
// Create a new instance of the StoryblokClient
const Storyblok = new StoryblokClient({
accessToken: '<YOUR_SPACE_ACCESS_TOKEN>',
cache: {
clear: 'auto',
type: 'memory',
},
});
// Check if _storyblok_release parameter is present in the URL
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const releaseId = urlParams.get('_storyblok_release') || null;
// Fetch the home story with the given releaseId
const response = await Storyblok.get('cdn/stories/home', {
version: 'draft',
from_release: releaseId,
})
For further information, please refer to the Storyblok JavaScript Client documentation.