npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

storyblok-schema-to-ts

v1.1.9

Published

Generate TypeScript types from Storyblok component schemas

Downloads

152

Readme

storyblok-schema-to-ts

Generate TypeScript types from Storyblok component schemas.

Prerequisites

  • Node.js >= 18

Authentication

The tool uses the Storyblok Management API to fetch component schemas and datasources. It resolves a token in this order:

  1. --token flag — pass your personal access token directly
  2. CLI credentials — reads from ~/.storyblok/credentials.json (created by npx storyblok login)

If no token is found, the tool shows instructions for obtaining one.

Get a personal access token at: https://app.storyblok.com/#/me/account?tab=token

Installation

npm install storyblok-schema-to-ts

CLI Usage

# With explicit token
npx storyblok-schema-to-ts --spaceId=123456 --token=your_token

# Using CLI credentials (after: npx storyblok login)
npx storyblok-schema-to-ts --spaceId=123456

# Non-EU region
npx storyblok-schema-to-ts --spaceId=123456 --region=us

# Custom output file
npx storyblok-schema-to-ts --spaceId=123456 --output=./types/storyblok.ts

# With custom prefixes
npx storyblok-schema-to-ts --spaceId=123456 --prefix=SB --builtinPrefix=SBCore

CLI Options

| Option | Description | Default | |--------|-------------|---------| | --spaceId | Storyblok space ID (required) | - | | --token | Personal access token | - | | --region | Storyblok region: eu, us, cn, ca, ap | eu | | --output | Output file path | SBGenerated.ts | | --prefix | Prefix for generated types | - | | --postfix | Postfix for generated types | - | | --builtinPrefix | Prefix for builtin types | - | | --builtinPostfix | Postfix for builtin types | - | | --capitalize | Capitalize type names | true | | --no-prettier | Skip prettier formatting | false | | --keep-temp | Keep .storyblok temp directory | false |

Programmatic Usage

import { generateTypes } from 'storyblok-schema-to-ts';

await generateTypes({
  spaceId: '123456',
  outputFile: 'types.ts',
  capitalize: true
});

Example Output

export interface Blok {
  _uid: string;
  component: string;
  _editable?: string;
}

export type Story<Content = Blok> = {
  alternates: Alternate[];
  content: Content;
  full_slug: string;
  id: number;
  name: string;
  slug: string;
  uuid: string;
  // ...
}

export type Hero = Blok & {
  component: "Hero";
  title: string;
  description?: string;
  theme?: "light" | "dark";
  image?: Asset;
  content?: RichText;
  items?: (Card | Button)[];
}

With --prefix=SB --builtinPrefix=SBCore, the output would use SBHero, SBCoreBlok, etc.

Deleted Component Warnings

When a field references components that no longer exist in the schema (e.g. via component_whitelist or filter_content_type), the generated types include an inline comment:

export type Page = Blok & {
  component: "Page";
  body?: (Hero | Card)[] /* [!] unknown component(s): DeletedSection */;
  related?: unknown /* [!] unknown component(s): OldWidget */;
}

This helps identify stale references without breaking TypeScript compilation.

License

MIT