Back to Blog
January 15, 20267 min readFrom Figma to

From Figma to Qwik: AI-Powered Code Generation

R
Replay Team
Developer Advocates

TL;DR: Ditch static design conversions; Replay leverages video analysis and AI to build dynamic Qwik applications directly from user behavior, offering a superior alternative to Figma-to-code tools.

The promise of AI-powered code generation has been tantalizingly close for years. We've seen tools that convert static designs from Figma, Sketch, or Adobe XD into code. But these tools fundamentally misunderstand the problem. Design is not the source of truth; user behavior is. Converting a static image into code misses the entire point of user experience. It's like trying to understand a symphony by looking at the sheet music without hearing the orchestra.

That's where Replay comes in.

The Flawed Logic of Figma-to-Code#

Figma-to-code tools have a fatal flaw: they treat the design as the endpoint instead of a starting point. A Figma file is a snapshot in time, a static representation of an intended user interface. It doesn't capture the nuances of user interaction, the dynamic state changes, or the underlying logic that brings an application to life.

Consider a simple login form. A Figma design will show the input fields and the "Submit" button. But it won't show:

  • Error handling for invalid credentials.
  • Loading states while the authentication request is in progress.
  • Transitions between different views after successful login.
  • Accessibility considerations like ARIA attributes and focus management.

These crucial aspects of the user experience are often left as an exercise for the developer, negating the supposed time savings of automated code generation. You're still left building the real application logic.

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

Replay takes a radically different approach. Instead of starting with a static design, we start with a video recording of a user interacting with an existing application or prototype. This video becomes the source of truth, capturing not just the visual appearance of the UI but also the behavior that drives it.

By analyzing the video, Replay's AI engine, powered by Gemini, can infer the user's intent, understand the data flow, and reconstruct the underlying code. This "Behavior-Driven Reconstruction" process allows Replay to generate code that is not only visually accurate but also functionally complete.

This is more than just "screenshot-to-code." It's about understanding what the user is trying to accomplish.

From Video to Qwik: A Step-by-Step Guide#

Let's walk through how to use Replay to generate a Qwik application from a video recording. Qwik's resumability and focus on performance make it an excellent target for AI-powered code generation.

Step 1: Record the User Flow#

Record a video of yourself (or a user) interacting with the application or prototype you want to reconstruct. This could be a screen recording of an existing website, a demo of a mobile app, or even a prototype built in a tool like Framer or ProtoPie. The more comprehensive the recording, the better. Capture all the key interactions, state changes, and edge cases.

💡 Pro Tip: Narrate your actions while recording. This provides valuable context for Replay's AI engine. For example, say "Now I'm entering my username and password" before typing in the credentials.

Step 2: Upload to Replay#

Upload the video to the Replay platform. Replay will automatically analyze the video, identify the UI elements, and infer the user's intent. This process can take a few minutes, depending on the length and complexity of the video.

Step 3: Review and Refine#

Once the analysis is complete, Replay will present you with a reconstructed UI and a proposed code implementation. Review the results carefully and make any necessary adjustments. You can edit the UI elements, modify the data bindings, and add custom logic.

📝 Note: Replay is constantly learning and improving. The more feedback you provide, the more accurate it will become over time.

Step 4: Generate Qwik Code#

Select Qwik as the target framework and generate the code. Replay will produce a Qwik project that you can download and run locally.

Here's an example of the kind of Qwik code Replay can generate:

typescript
// src/components/LoginFormComponent.tsx import { component$, useSignal, $, useContext } from '@builder.io/qwik'; import { AuthContext } from '~/contexts/auth-context'; export const LoginFormComponent = component$(() => { const username = useSignal(''); const password = useSignal(''); const error = useSignal<string | null>(null); const isLoading = useSignal(false); const authContext = useContext(AuthContext); const handleLogin = $(async () => { isLoading.value = true; error.value = null; try { await authContext.login(username.value, password.value); } catch (e: any) { error.value = e.message || 'Login failed'; } finally { isLoading.value = false; } }); return ( <form onSubmit$={handleLogin}> {error.value && <div class="error">{error.value}</div>} <label> Username: <input type="text" bind:value={username.value} /> </label> <label> Password: <input type="password" bind:value={password.value} /> </label> <button type="submit" disabled={isLoading.value}> {isLoading.value ? 'Logging in...' : 'Login'} </button> </form> ); });

This code snippet demonstrates several key features:

  • Qwik components: The code is structured as a Qwik component, leveraging Qwik's resumability features.
  • Signals:
    text
    useSignal
    is used for managing state, ensuring efficient updates.
  • Context:
    text
    useContext
    accesses an authentication context, demonstrating integration with application-wide state.
  • Asynchronous operations: The
    text
    handleLogin
    function uses
    text
    async/await
    to handle asynchronous authentication requests.
  • Error handling: The code includes error handling to display error messages to the user.
  • Loading states: The
    text
    isLoading
    signal is used to disable the button and display a loading message while the authentication request is in progress.

Step 5: Integrate with Supabase (Optional)#

Replay can also automatically integrate with Supabase, a popular open-source Firebase alternative. This allows you to quickly connect your Qwik application to a backend database and authentication system. Replay can generate the necessary Supabase client code and configure the database schema based on the data models inferred from the video.

Replay vs. Figma-to-Code: A Head-to-Head Comparison#

Here's a comparison of Replay and traditional Figma-to-code tools:

FeatureFigma-to-CodeReplay
InputStatic Design (Figma, Sketch)Video Recording
Understanding User Intent
Handling Dynamic StateLimited
Generating Functional CodePartial
Supabase IntegrationManualAutomated
Multi-Page GenerationLimited
Style InjectionPartial
Product Flow Maps

As you can see, Replay offers a significant advantage in terms of understanding user intent, handling dynamic state, and generating functional code.

The Benefits of Behavior-Driven Code Generation#

  • Faster Development: Replay automates the tedious task of manually coding UI elements and connecting them to backend logic.
  • Improved Accuracy: By analyzing real user behavior, Replay generates code that is more likely to meet the user's needs.
  • Reduced Errors: Replay's AI engine can identify potential errors and inconsistencies in the user flow, helping you to catch bugs early.
  • Better User Experience: By focusing on behavior rather than design, Replay helps you to create applications that are more intuitive and user-friendly.
  • Enhanced Collaboration: Replay provides a shared understanding of the user experience, facilitating collaboration between designers, developers, and product managers.

⚠️ Warning: Replay is not a magic bullet. It still requires human oversight and refinement. However, it can significantly accelerate the development process and improve the quality of your code.

Frequently Asked Questions#

Is Replay free to use?#

Replay offers a free tier with limited features. Paid plans are available for users who need more advanced capabilities.

How is Replay different from v0.dev?#

V0.dev is a text-to-code tool, relying on prompts to generate code snippets. Replay uses video input, allowing it to understand user behavior and generate more complete and functional applications. Replay's "Behavior-Driven Reconstruction" focuses on the how and why of user interactions, while v0.dev primarily focuses on the what.

Can Replay handle complex applications?#

Replay is designed to handle a wide range of applications, from simple landing pages to complex web applications. However, the complexity of the video recording will impact the accuracy and completeness of the generated code.

What frameworks does Replay support?#

Currently, Replay supports Qwik. 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