Tutorial

How to Sync Modly with Storybook in Under 10 Minutes

Stop manually copying tokens. Connect your Modly design system to Storybook for live, automated synchronization.

By Alex Chen — Published on Oct 24, 2023

Prerequisites

Before you begin, ensure your environment is set up correctly to avoid configuration friction later.

Storybook 7+

Our addon relies on Storybook's new component metadata API (v7.0+) introduced in 2022.

Modly Growth Plan

Token sync and module publishing features are available on the Growth and Enterprise tiers.

GitHub Repo

Your Storybook repository must be connected to your Modly workspace to receive the sync signal.

Step 1: Install the Modly Storybook addon

Open your terminal in your Storybook project directory and run the installation command.

npm install @modly/storybook-addon

Step 2: Configure your modly.config.js

Import the addon and configure the sync settings in your Storybook main configuration file.

import { configure } from '@storybook/react';
import { withModly } from '@modly/storybook-addon';

// Configure the addon with your workspace ID
const config = {
  addons: ['@modly/storybook-addon'],
  core: { disableStoryshots: true },
  modly: {
    workspaceId: 'ws_5f8a9b1c2d3e4f6a',
    autoSync: true,
    themes: ['light', 'dark']
  }
};

configure(stories => {
  stories.addStoriesWithAddon(withModly);
}, config);

Step 3: Map tokens to your Storybook theme

Once installed, open Storybook and navigate to the new Modly tab. Select a theme (e.g., "Light") and map your Modly color tokens to Storybook's global CSS variables.

Modly Storybook addon settings showing token mapping configuration panel

Step 4: Enable auto-publish on merge

Configure a GitHub Actions workflow to automatically publish your Storybook modules to Modly whenever you push to the main branch.

name: Publish to Modly
on:
  push:
    branches: [ main ]

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Install Modly CLI
        run: npm install -g @modly/cli
      - name: Publish Modules
        run: modly publish --repo=modly/my-storybook-app --branch=main

This workflow runs automatically on every successful push, ensuring your documentation is always up to date.

The Result: Live Sync

After the configuration is complete, you will see a live badge on your component stories indicating the Modly version. When you update a token in Figma, the change appears in Storybook immediately without refreshing.

*Note: In a real environment, you would see an animated GIF here showing the visual update propagating from the Modly dashboard to the Storybook preview panel.*

Troubleshooting Common Errors

Error 404

Module not found in registry. Ensure your workspaceId in modly.config.js matches the ID in your Modly dashboard settings.

Error 500

Sync server timeout. Check your GitHub Actions logs for network connectivity issues or rate limits from the Modly API.

About the Author

Alex Chen is a Senior Frontend Engineer at Modly. He focuses on developer tooling and design system infrastructure. He previously built component libraries at Scale AI and Stripe.

Follow Alex on LinkedIn