Storyblok CLI

4.16.9 · active · verified Wed Apr 22

The Storyblok CLI (Command Line Interface) is a powerful development tool designed to enhance the developer experience for projects integrating with the Storyblok Headless CMS. It provides a robust set of features for managing Storyblok spaces directly from the terminal, including generating TypeScript type definitions for components to ensure type safety in frontend applications. The current stable version is 4.16.9, released very recently, indicating an active development and release cadence, often as part of a monorepo that includes various Storyblok SDKs. Key differentiators include its comprehensive component management capabilities (pulling, pushing schemas, groups, presets, tags), a flexible migration system for content updates, secure authentication across regions, and advanced filtering options. It focuses on improving workflow efficiency with features like organized file structures, customizable paths, and a dry run mode for migrations.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to install the Storyblok CLI globally, log in, pull component schemas, generate TypeScript types, and run a basic content migration with a dry run.

npm install -g storyblok
storyblok login
# Follow the prompts to enter your personal access token

# Pull all component schemas from your space
storyblok pull-components --space=<YOUR_SPACE_ID> --path=./src/storyblok/components

# Generate TypeScript types for your components
storyblok generate-types --path=./src/storyblok/types.d.ts

# Run a simple migration (example: rename a field)
# First, create a migration file, e.g., 'storyblok/migrations/001-rename-field.js'
// storyblok/migrations/001-rename-field.js
module.exports = { 
  up: async (api) => {
    console.log('Running migration: Rename old_field to new_field');
    // Example: Find a component and rename a field
    // await api.put('spaces/YOUR_SPACE_ID/components/COMPONENT_ID', { component: { schema: { new_field: { type: 'text' } } } });
  },
  down: async (api) => {},
};
storyblok migrate --space=<YOUR_SPACE_ID> --path=./storyblok/migrations --dry-run
storyblok migrate --space=<YOUR_SPACE_ID> --path=./storyblok/migrations

view raw JSON →