Storybook Deployment Guide โ
Complete guide for deploying the Storybook component library to storybook.ourlantern.app and storybook.dev.ourlantern.app.
Overview โ
The Storybook site is separate from the main Lantern app and documentation, with its own deployment pipeline:
| Component | Production | Development |
|---|---|---|
| Main App | ourlantern.app | dev.ourlantern.app |
| Docs Site | docs.ourlantern.app | docs.dev.ourlantern.app |
| Storybook | storybook.ourlantern.app | storybook.dev.ourlantern.app |
Key Benefits:
- Stakeholders can view and interact with components without local setup
- Designers can review component variations and documentation
- Developers can share component examples via URLs
- Independent deployment from main app
- Automatic preview URLs for component changes
Deployment Flow โ
Push to GitHub (main or dev branch)
โ
Cloudflare Pages Git Integration
โ
Build static Storybook (npm run build-storybook)
โ
Deploy to Cloudflare Pages
โ
Available at storybook.ourlantern.app (main) or storybook.dev.ourlantern.app (dev)Automatic Deployments โ
- main branch โ
storybook.ourlantern.app(production) - dev branch โ
storybook.dev.ourlantern.app(development) - feature branches โ Preview URLs (e.g.,
feature-xyz.lantern-storybook-dev.pages.dev)
Quick Start โ
Local Development โ
# Start the Storybook dev server
npm run storybook
# Build Storybook for production (static site)
npm run build-storybook
# Preview the production build
npx http-server storybook-staticThe dev server runs on http://localhost:6006 by default.
Initial Setup in Cloudflare โ
Step 1: Create Production Storybook Project โ
- Go to Cloudflare Dashboard โ Pages
- Click "Create a project" โ "Connect to Git"
- Select
cattreedev/lantern_apprepository - Configure:
- Project name:
lantern-storybook - Production branch:
main - Build command:
npm run build-storybook - Build output directory:
storybook-static - Root directory: (leave empty)
- Project name:
- Click "Save and Deploy"
Step 2: Create Development Storybook Project โ
- Click "Create a project" again
- Select same repo
cattreedev/lantern_app - Configure:
- Project name:
lantern-storybook-dev - Production branch:
dev(not main!) - Build command:
npm run build-storybook - Build output directory:
storybook-static - Root directory: (leave empty)
- Project name:
- Click "Save and Deploy"
Step 3: Add Custom Domains โ
Production Storybook โ
- In
lantern-storybookproject, go to Custom domains - Click Set up a custom domain
- Enter
storybook.ourlantern.app - Cloudflare will auto-create the required DNS records
Development Storybook โ
- In
lantern-storybook-devproject, go to Custom domains - Click Set up a custom domain
- Enter
storybook.dev.ourlantern.app - Cloudflare will auto-create the required DNS records
Step 4: Verify DNS Configuration โ
In Cloudflare dashboard, DNS tab should show:
CNAME storybook โ lantern-storybook.pages.dev (Proxied)
CNAME storybook.dev โ lantern-storybook-dev.pages.dev (Proxied)Note: These are in addition to your existing DNS records:
CNAME @ โ lantern-app.pages.dev (Proxied)
CNAME dev โ lantern-app-dev.pages.dev (Proxied)
CNAME docs โ lantern-docs.pages.dev (Proxied)
CNAME docs.dev โ lantern-docs-dev.pages.dev (Proxied)Deployment Workflow โ
Updating Storybook โ
1. Make Changes โ
# Create a feature branch
git checkout -b feature/update-button-story dev
# Add or update stories
# Stories are in src/**/*.stories.jsx
# Test locally
npm run storybook2. Preview Changes โ
# Build static Storybook
npm run build-storybook
# Verify the build
ls -la storybook-static/
# Optional: preview locally
npx http-server storybook-static3. Push to GitHub โ
git add .
git commit -m "Add button variants to Storybook"
git push origin feature/update-button-storyResult: Cloudflare creates a preview URL automatically:
https://feature-update-button-story.lantern-storybook-dev.pages.dev- Share this URL with stakeholders for review!
4. Merge to Dev โ
After review:
git checkout dev
git merge feature/update-button-story
git push origin devResult: Deploys to https://storybook.dev.ourlantern.app
5. Deploy to Production โ
When ready for production:
git checkout main
git merge dev
git push origin mainResult: Deploys to https://storybook.ourlantern.app
Managing Access (Optional) โ
Public Access (Recommended for Stakeholders) โ
By default, Storybook sites are public. This is ideal for:
- Sharing with designers and product managers
- External stakeholder reviews
- Component library documentation
Restricted Access (If Needed) โ
If you need to restrict access:
- Go to Cloudflare Zero Trust โ Access โ Applications
- Click Add an application โ Self-hosted
- Configure:
- Application name:
lantern-storybook - Domain:
storybook.ourlantern.app - Policy: Choose authentication method (PIN, email, etc.)
- Application name:
- Repeat for dev environment if needed
Note: For stakeholder access, keeping it public is usually better.
Using Storybook for Reviews โ
Sharing Components with Stakeholders โ
Direct links to components:
https://storybook.ourlantern.app/?path=/story/components-button--defaultCanvas mode (component only):
https://storybook.ourlantern.app/iframe.html?id=components-button--defaultDocs mode (with documentation):
https://storybook.ourlantern.app/?path=/docs/components-button--docs
Preview URLs for Feature Branches โ
Every feature branch gets a preview URL:
https://[branch-name].lantern-storybook-dev.pages.devShare these URLs in:
- Pull request descriptions
- Slack/email for design reviews
- Jira/Linear tickets
- Design handoff documents
Troubleshooting โ
Build Fails in Cloudflare โ
Check the build logs:
- Go to Cloudflare Dashboard โ Pages โ your project
- Click on the failed deployment
- View the build log
Common issues:
- Missing dependencies: Check
package.jsonhas all Storybook packages - Build command wrong: Should be
npm run build-storybook - Output directory wrong: Should be
storybook-static
Storybook Shows Blank Page โ
Possible causes:
- Base path misconfiguration
- Missing static assets
- Build didn't complete successfully
Fix:
- Build locally:
npm run build-storybook - Check
storybook-static/has files - Look for JavaScript errors in browser console
Stories Not Updating โ
Ensure you're looking at the right environment:
- Production (
mainbranch):storybook.ourlantern.app - Development (
devbranch):storybook.dev.ourlantern.app - Feature branch:
[branch-name].lantern-storybook-dev.pages.dev
Force a rebuild:
- Go to Cloudflare Pages โ Deployments
- Click "Retry deployment" on the latest build
Custom Domain Not Working โ
Check DNS records:
nslookup storybook.ourlantern.app
# Should resolve to lantern-storybook.pages.devIf not resolving:
- Go to Cloudflare Dashboard โ DNS
- Verify CNAME record exists and is proxied (orange cloud)
- Wait 5-10 minutes for DNS propagation
Build Configuration โ
Wrangler Config โ
The wrangler.storybook.toml file defines the build configuration:
name = "lantern-storybook"
compatibility_date = "2026-01-03"
[pages]
build_command = "npm run build-storybook"
build_output_directory = "storybook-static"
node_version = "20"Package.json Scripts โ
{
"scripts": {
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
}
}Best Practices โ
Development Workflow โ
- Always test locally first:
npm run storybook - Build before pushing:
npm run build-storybookto catch build errors - Use feature branches: Get preview URLs for reviews
- Merge to dev first: Test on dev environment before production
- Keep stories updated: Add stories for new components immediately
Stakeholder Communication โ
- Share preview URLs early: Get feedback during development
- Use descriptive branch names: Makes preview URLs clearer
- Add documentation to stories: Use MDX or description fields
- Group related components: Use consistent naming in story titles
Performance โ
- Optimize images: Use compressed images in stories
- Lazy load large components: Use code splitting if needed
- Monitor build times: Keep builds under 5 minutes
Related Documentation โ
- DEPLOYMENT.md โ Main app deployment guide
- DOCS_DEPLOYMENT.md โ Documentation site deployment
- SUBDOMAINS_AND_ACCESS.md โ DNS and access management
docs/storybook/STORYBOOK.mdโ Storybook usage guidedocs/storybook/ADDING_STORIES.mdโ How to add new stories
Quick Reference โ
URLs โ
| Environment | URL |
|---|---|
| Production Storybook | https://storybook.ourlantern.app |
| Dev Storybook | https://storybook.dev.ourlantern.app |
| Preview (feature branch) | https://[branch-name].lantern-storybook-dev.pages.dev |
Commands โ
# Local development
npm run storybook
# Build static site
npm run build-storybook
# Preview build
npx http-server storybook-static
# Push and deploy
git push origin [branch-name]Cloudflare Projects โ
- Production:
lantern-storybook(main branch โ storybook.ourlantern.app) - Development:
lantern-storybook-dev(dev branch โ storybook.dev.ourlantern.app)