Back to Blog
January 5, 20266 min readReplay AI: Creating

Replay AI: Creating Component Storybook From Video UI With Code Assets

R
Replay Team
Developer Advocates

TL;DR: Replay AI leverages video analysis to automatically generate React component Storybooks, complete with code assets, offering a faster and more accurate alternative to traditional screenshot-to-code or manual methods.

The era of static screenshot-to-code is over. It's a fundamentally flawed approach that misses the crucial element: user behavior. We've all been there, staring at a generated component that looks right but falls apart the moment you try to integrate it into a real application. The problem? Screenshots only capture the visual state, not the intent behind the UI.

The Problem with Screenshot-to-Code#

Current tools rely on static images, resulting in:

  • Lack of Context: They can't understand dynamic behavior like animations, form submissions, or state changes.
  • Brittle Components: The generated code is often tightly coupled to the specific screenshot, making it difficult to reuse or adapt.
  • Manual Rework: Developers spend significant time debugging and refactoring the generated code to make it functional.

These tools promise speed but deliver frustration. They create more work than they save.

Behavior-Driven Reconstruction: Video as the Source of Truth#

Replay takes a radically different approach. Instead of relying on static images, Replay analyzes video recordings of user interactions. This "Behavior-Driven Reconstruction" allows Replay to understand the intent behind the UI, not just its visual appearance.

Replay leverages Gemini to dissect every frame, tracking:

  • User Input: Mouse clicks, keyboard entries, and touch gestures.
  • State Changes: How the UI responds to user actions.
  • Data Flow: API calls and data manipulation.

This comprehensive understanding enables Replay to generate more accurate, robust, and reusable code.

Creating Component Storybooks with Replay#

One of the most powerful applications of Replay is the automatic generation of React component Storybooks. Storybook is an invaluable tool for developing UI components in isolation, making it easier to test, document, and reuse them across projects. However, creating Storybooks manually can be time-consuming and tedious.

Replay streamlines this process by automatically generating Storybook stories from video recordings. Here's how it works:

Step 1: Record the UI Interaction#

Record a video of yourself interacting with the UI component you want to generate a Storybook for. Be sure to demonstrate all the different states and behaviors of the component. For example, if you're creating a Storybook for a button, show the default state, the hover state, the active state, and the disabled state.

💡 Pro Tip: The clearer and more comprehensive your video, the better the resulting Storybook will be. Narrate your actions if possible.

Step 2: Upload the Video to Replay#

Upload the video to Replay. Replay will analyze the video and generate a React component and its corresponding Storybook story.

Step 3: Review and Customize the Generated Code#

Review the generated code and make any necessary customizations. Replay provides a visual editor that allows you to easily modify the component's code, styles, and props. You can also add additional documentation and examples to the Storybook story.

Step 4: Integrate the Storybook into Your Project#

Integrate the generated Storybook into your project. You can use the Storybook CLI to export the Storybook as a static website or integrate it directly into your development environment.

Here's an example of a generated Storybook story:

typescript
// Button.stories.tsx import React from 'react'; import { ComponentStory, ComponentMeta } from '@storybook/react'; import { Button } from './Button'; export default { title: 'Example/Button', component: Button, argTypes: { backgroundColor: { control: 'color' }, onClick: { action: 'clicked' }, }, } as ComponentMeta<typeof Button>; const Template: ComponentStory<typeof Button> = (args) => <Button {...args} />; export const Primary = Template.bind({}); Primary.args = { primary: true, label: 'Button', }; export const Secondary = Template.bind({}); Secondary.args = { label: 'Button', }; export const Large = Template.bind({}); Large.args = { size: 'large', label: 'Button', }; export const Small = Template.bind({}); Small.args = { size: 'small', label: 'Button', };

This code was automatically generated by Replay from a video recording of a user interacting with a button component. The Storybook story includes examples of the button in different states and sizes, as well as controls for modifying the button's props.

Replay Features in Action#

Replay goes beyond basic code generation. It leverages its video understanding to provide advanced features:

  • Multi-Page Generation: Replay can analyze multi-page flows, generating code for entire user journeys.
  • Supabase Integration: Seamlessly integrate your generated components with your Supabase backend.
  • Style Injection: Replay understands and preserves your existing styling conventions.
  • Product Flow Maps: Visualize and understand the user flows captured in your videos.

Replay vs. The Competition#

FeatureScreenshot-to-Codev0.devReplay
Video Input
Behavior AnalysisPartial (Prompt-Based)
Storybook GenerationLimitedLimited
Multi-Page Support
Style InjectionLimitedLimited
Supabase Integration

📝 Note: v0.dev relies heavily on prompt engineering, which can be unpredictable and require significant iteration. Replay, on the other hand, uses video analysis to understand the user's intent, resulting in more accurate and reliable code generation.

The Benefits of Using Replay#

  • Faster Development: Automatically generate React components and Storybooks in seconds.
  • Improved Accuracy: Replay understands user behavior, resulting in more accurate and robust code.
  • Increased Reusability: Generate reusable components that can be easily integrated into your projects.
  • Reduced Debugging: Spend less time debugging and refactoring generated code.
  • Better Documentation: Automatically generate Storybook stories with clear examples and documentation.

⚠️ Warning: While Replay significantly reduces development time, it's crucial to review and customize the generated code to ensure it meets your specific requirements.

Frequently Asked Questions#

Is Replay free to use?#

Replay offers a free tier with limited usage. Paid plans are available for higher usage and access to advanced features.

How is Replay different from v0.dev?#

v0.dev uses text prompts to generate code, while Replay analyzes video recordings of user interactions. Replay's behavior-driven approach results in more accurate and robust code generation, especially for complex UI components and multi-page flows. Replay understands the intent behind the UI, not just the visual state.

What kind of videos work best with Replay?#

Clear, well-lit videos with minimal background noise work best. Be sure to demonstrate all the different states and behaviors of the UI component you want to generate a Storybook for. Narrating your actions can also help Replay understand your intent.

What frameworks does Replay support?#

Currently, Replay primarily supports React. Support for other frameworks is planned for the future.


Ready to try behavior-driven code generation? Get started with Replay - transform any video into working code in seconds.

Ready to try Replay?

Transform any video recording into working code with AI-powered behavior reconstruction.

Launch Replay Free