Storyblok Raises $80M Series C - Read News

Skip to main content

How to view a release in a preview environment

  • FAQ
  • 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.

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 iframe src 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 

Storyblok release in URL parameter
  • 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

        
      
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,
})
    

hint:

For further information, please refer to the Storyblok JavaScript Client documentation.