Back to Blog
January 8, 20267 min readSolidJS Reusable Components

SolidJS Reusable Components from Video Capture

R
Replay Team
Developer Advocates

TL;DR: Replay empowers developers to rapidly generate reusable SolidJS components from video recordings, leveraging behavior-driven reconstruction to understand user intent and create functional UI.

From Video to SolidJS: Building Reusable Components with Replay#

The traditional design-to-code workflow is broken. Manually translating mockups or design specs into working components is tedious, error-prone, and time-consuming. What if you could capture a user interaction, and automatically generate the corresponding SolidJS code?

That's the promise of Replay. It analyzes video recordings of user interfaces and, using Gemini, reconstructs functional code, understanding what the user is trying to do, not just what they see. This unlocks a powerful workflow for rapidly prototyping, iterating on designs, and building reusable components.

Understanding Behavior-Driven Reconstruction#

Replay employs "Behavior-Driven Reconstruction." This means it doesn't just take a static snapshot of the UI. Instead, it analyzes the video to understand the sequence of user actions, state transitions, and data flow. This allows Replay to generate code that accurately reflects the intended behavior of the UI, resulting in more robust and maintainable components.

Consider a simple example: a user clicks a button to open a modal. A screenshot-to-code tool would only see the modal in its final state. Replay, however, understands the action (the button click) that triggered the state change. This allows it to generate code that includes the button click handler and the modal's visibility logic.

Replay vs. Traditional Code Generation Tools#

Here's a comparison of Replay with other code generation approaches:

FeatureScreenshot-to-CodeDesign-to-Code (Figma plugins)Replay
InputStatic ImagesDesign FilesVideo
Behavior AnalysisLimited (based on design annotations)
Understanding User IntentLimited
Reusable Component GenerationBasicImproved, but often requires manual adjustmentsAdvanced, with behavior-driven logic
Multi-Page SupportPartial
FidelityVisually accurate, but often lacks functionalityDepends on design system and plugin capabilitiesHigh, with functional accuracy

As you can see, Replay offers a unique advantage by leveraging video input and behavior analysis. This allows it to generate more complete, functional, and reusable components compared to traditional approaches.

Building a SolidJS Component from Video: A Step-by-Step Guide#

Let's walk through a practical example of using Replay to generate a reusable SolidJS component. We'll assume you have a video recording of a simple form with input fields and a submit button.

Step 1: Upload the Video to Replay#

First, upload your video recording to the Replay platform. Replay supports various video formats and resolutions.

Step 2: Replay Analyzes the Video and Reconstructs the UI#

Replay will analyze the video, identify UI elements, and reconstruct the application's structure and behavior. This process typically takes a few seconds to a minute, depending on the video's length and complexity.

Step 3: Review and Refine the Generated Code#

Once the analysis is complete, Replay will present you with the generated code. You can review the code, make any necessary adjustments, and download it as a SolidJS component.

Here's an example of the kind of code Replay might generate for a simple form:

typescript
import { createSignal, Component } from 'solid-js'; interface Props { onSubmit: (data: { name: string; email: string }) => void; } const MyForm: Component<Props> = (props) => { const [name, setName] = createSignal(''); const [email, setEmail] = createSignal(''); const handleSubmit = (event: Event) => { event.preventDefault(); props.onSubmit({ name: name(), email: email() }); }; return ( <form onSubmit={handleSubmit}> <div> <label htmlFor="name">Name:</label> <input type="text" id="name" value={name()} onChange={(e) => setName(e.currentTarget.value)} /> </div> <div> <label htmlFor="email">Email:</label> <input type="email" id="email" value={email()} onChange={(e) => setEmail(e.currentTarget.value)} /> </div> <button type="submit">Submit</button> </form> ); }; export default MyForm;

💡 Pro Tip: Replay often infers prop types and event handlers based on the video analysis, saving you significant boilerplate code.

Step 4: Integrate the Component into Your SolidJS Application#

You can now integrate the generated component into your SolidJS application. Simply import the component and use it like any other SolidJS component.

typescript
import MyForm from './MyForm'; const App = () => { const handleSubmit = (data: { name: string; email: string }) => { console.log('Form data:', data); // Perform further actions with the form data }; return ( <div> <h1>My Application</h1> <MyForm onSubmit={handleSubmit} /> </div> ); }; export default App;

Advanced Features: Beyond Basic Component Generation#

Replay offers several advanced features that go beyond basic component generation:

  • Multi-Page Generation: Replay can analyze videos that span multiple pages or views, allowing you to generate complex application flows.
  • Supabase Integration: Replay can be configured to automatically connect to your Supabase database, enabling seamless data integration.
  • Style Injection: Replay can inject CSS styles into the generated components, ensuring visual consistency with your application's design.
  • Product Flow Maps: Replay can generate visual maps of the user flows captured in the video, providing valuable insights into user behavior.

📝 Note: The quality of the generated code depends on the clarity and quality of the video recording. Ensure your videos are well-lit and free of distractions.

Benefits of Using Replay for SolidJS Development#

Using Replay for SolidJS development offers several key benefits:

  • Increased Development Speed: Generate components in seconds, rather than hours or days.
  • Improved Code Quality: Behavior-driven reconstruction ensures code accurately reflects user intent.
  • Reduced Boilerplate: Replay automatically generates boilerplate code, such as prop types and event handlers.
  • Enhanced Collaboration: Easily share video recordings and generated code with your team.
  • Rapid Prototyping: Quickly prototype new features and iterate on designs.

⚠️ Warning: While Replay significantly accelerates development, it's essential to review and test the generated code thoroughly to ensure it meets your specific requirements.

Reusable Components and Design Systems#

Replay is especially powerful when used in conjunction with design systems. By capturing videos of existing components within your design system, you can quickly generate new variations or extensions of those components. This ensures consistency and maintainability across your application.

For example, if you have a standard button component in your design system, you can capture a video of a modified version of that button (e.g., with a different color or icon) and use Replay to generate the code for the new variation. This eliminates the need to manually write the code from scratch, saving you time and effort.

typescript
// Example of extending a base Button component import Button from './BaseButton'; // Assume BaseButton is part of your design system import { createSignal, Component } from 'solid-js'; interface Props { onClick: () => void; label: string; } const PrimaryButton: Component<Props> = (props) => { return ( <Button onClick={props.onClick} class="primary-button"> {props.label} </Button> ); }; export default PrimaryButton;

This leverages the existing

text
Button
component from your design system and applies a specific style (
text
primary-button
) to create a new, reusable component. Replay can help you rapidly generate these kinds of variations from video examples.

Frequently Asked Questions#

Is Replay free to use?#

Replay offers a free tier with limited functionality. Paid plans are available for more advanced features and higher usage limits. Check the Replay pricing page for details.

How is Replay different from v0.dev?#

While both Replay and v0.dev aim to accelerate UI development, they differ in their approach. v0.dev uses AI to generate code based on text prompts. Replay, on the other hand, uses video analysis to understand user behavior and reconstruct functional UI. This allows Replay to capture more nuanced interactions and generate more accurate and robust code.

What frameworks does Replay support?#

Currently, Replay primarily supports React, SolidJS, and Vue.js. Support for other frameworks is planned for future releases.

What types of videos work best with Replay?#

Videos that clearly demonstrate the UI's structure and behavior work best. Ensure your videos are well-lit, stable, and free of distractions.


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