Back to Blog
January 18, 20268 min readGenerating UI Code

Generating UI Code from User Journey Recordings

R
Replay Team
Developer Advocates

TL;DR: Replay leverages video analysis and Gemini AI to generate working UI code directly from recordings of user journeys, enabling rapid prototyping and efficient UI development.

Stop Designing, Start Replaying: Generating UI Code from User Journey Recordings#

The traditional UI development process is often a bottleneck. Wireframes, mockups, and iterative design reviews consume valuable time. What if you could skip the static design phase and jump directly to functional code, driven by actual user behavior? That's the promise of behavior-driven reconstruction, and it's now a reality with Replay.

Replay is a revolutionary video-to-code engine that uses Gemini to reconstruct working UI from screen recordings. Unlike screenshot-to-code tools that only understand visual elements, Replay analyzes video to understand user behavior and intent. This "Behavior-Driven Reconstruction" treats video as the source of truth, leading to more accurate and functional code generation.

The Problem with Traditional UI Development#

Consider the typical workflow:

  1. User Research: Conduct user interviews and gather feedback.
  2. Wireframing/Mockups: Create static representations of the UI.
  3. Design Review: Iterate on the design based on feedback.
  4. Hand-off to Developers: Translate the design into code.
  5. Testing and Refinement: Identify and fix bugs, adjust the UI based on real-world usage.

This process is inherently slow and prone to misinterpretation. Developers may struggle to accurately implement the intended user experience based solely on static designs. Furthermore, the disconnect between design and development can lead to costly rework.

Introducing Behavior-Driven Reconstruction#

Replay offers a fundamentally different approach. By analyzing video recordings of user journeys, Replay understands what users are trying to achieve and how they interact with the UI. This allows Replay to generate code that accurately reflects the intended user experience.

Here's a breakdown of how Replay works:

  1. Record a User Journey: Capture a video of a user interacting with an existing application or a prototype. This video serves as the "source of truth" for the desired UI.
  2. Upload to Replay: Upload the video to the Replay platform.
  3. AI-Powered Analysis: Replay uses Gemini AI to analyze the video, identifying UI elements, user interactions, and underlying logic.
  4. Code Generation: Replay generates clean, functional code based on the video analysis.
  5. Integration: Integrate the generated code into your existing project.

Replay: Key Features#

Replay is packed with features designed to streamline UI development:

  • Multi-page Generation: Generate code for entire user flows spanning multiple pages.
  • Supabase Integration: Seamlessly connect your Replay-generated UI to a Supabase backend.
  • Style Injection: Customize the look and feel of your UI with CSS or Tailwind CSS.
  • Product Flow Maps: Visualize the user journey and understand the flow of interactions.

Replay vs. Screenshot-to-Code Tools#

FeatureScreenshot-to-CodeReplay
InputScreenshotsVideo
Behavior Analysis
Intent Understanding
Multi-Page SupportLimited
Code QualityBasicHigh, Functional

💡 Pro Tip: When recording user journeys, speak aloud what you are trying to accomplish. This provides valuable context for Replay's AI engine.

A Practical Example: Building a Simple To-Do App#

Let's walk through a simple example of using Replay to generate code for a basic to-do app.

Step 1: Record the User Journey#

Record a video of yourself interacting with a to-do app (either an existing app or a prototype). In the video, demonstrate the following actions:

  1. Adding a new to-do item.
  2. Marking a to-do item as complete.
  3. Deleting a to-do item.

Step 2: Upload to Replay#

Upload the video to the Replay platform. Replay will begin analyzing the video and identifying the UI elements and user interactions.

Step 3: Review and Refine (Optional)#

Replay provides a visual representation of the identified UI elements and interactions. You can review this representation and make any necessary adjustments.

Step 4: Generate Code#

Click the "Generate Code" button. Replay will generate the code for your to-do app, including the UI components, event handlers, and data management logic.

Step 5: Integrate into Your Project#

Download the generated code and integrate it into your existing project. You can customize the code further to meet your specific requirements.

Code Example: Generated React Component#

Here's an example of the React code that Replay might generate for the to-do app:

typescript
// Generated by Replay import React, { useState } from 'react'; interface Todo { id: number; text: string; completed: boolean; } const TodoApp = () => { const [todos, setTodos] = useState<Todo[]>([ { id: 1, text: 'Learn Replay', completed: false }, ]); const [newTodoText, setNewTodoText] = useState(''); const handleAddTodo = () => { if (newTodoText.trim() !== '') { const newTodo: Todo = { id: todos.length + 1, text: newTodoText, completed: false, }; setTodos([...todos, newTodo]); setNewTodoText(''); } }; const handleToggleComplete = (id: number) => { setTodos( todos.map((todo) => todo.id === id ? { ...todo, completed: !todo.completed } : todo ) ); }; const handleDeleteTodo = (id: number) => { setTodos(todos.filter((todo) => todo.id !== id)); }; return ( <div> <h1>To-Do List</h1> <input type="text" value={newTodoText} onChange={(e) => setNewTodoText(e.target.value)} /> <button onClick={handleAddTodo}>Add</button> <ul> {todos.map((todo) => ( <li key={todo.id}> <input type="checkbox" checked={todo.completed} onChange={() => handleToggleComplete(todo.id)} /> <span style={{ textDecoration: todo.completed ? 'line-through' : 'none' }}> {todo.text} </span> <button onClick={() => handleDeleteTodo(todo.id)}>Delete</button> </li> ))} </ul> </div> ); }; export default TodoApp;

This code provides a basic functional to-do app with the ability to add, complete, and delete items. This is just a starting point; you can further customize the code to add more features and styling.

⚠️ Warning: While Replay generates functional code, it's important to review and test the code thoroughly to ensure it meets your specific requirements.

The Benefits of Using Replay#

  • Faster Prototyping: Quickly generate working prototypes based on real user behavior.
  • Improved Accuracy: Ensure that the UI accurately reflects the intended user experience.
  • Reduced Rework: Minimize the risk of misinterpretation and costly rework.
  • Increased Efficiency: Streamline the UI development process and free up developers to focus on more complex tasks.
  • Enhanced Collaboration: Facilitate better communication between designers and developers.

📝 Note: Replay is constantly evolving, with new features and improvements being added regularly.

Real-World Use Cases#

Replay is applicable to a wide range of use cases, including:

  • Rapid Prototyping: Quickly create interactive prototypes for user testing.
  • UI Refactoring: Generate code for existing UIs based on user recordings.
  • Component Library Generation: Create reusable UI components from video demonstrations.
  • Automated Testing: Generate test cases based on user interactions.

Integrating with Supabase#

Replay seamlessly integrates with Supabase, allowing you to quickly connect your generated UI to a powerful backend. This integration simplifies the process of storing and managing data, and it enables you to build full-stack applications with ease.

To integrate with Supabase, you simply need to provide your Supabase API key and URL to Replay. Replay will then automatically generate the necessary code to interact with your Supabase database.

Style Injection with Tailwind CSS#

Replay supports style injection, allowing you to customize the look and feel of your generated UI with CSS or Tailwind CSS. This feature provides you with complete control over the visual appearance of your application.

You can either provide custom CSS styles or use Tailwind CSS classes to style your UI elements. Replay will automatically apply these styles to the generated code.

Frequently Asked Questions#

Is Replay free to use?#

Replay offers a free tier with limited usage. Paid plans are available for users who require more features and higher usage limits. Check the Replay website for current pricing details.

How is Replay different from v0.dev?#

While both tools aim to generate code, Replay's key differentiator is its video-driven approach. v0.dev relies on text prompts, whereas Replay analyzes actual user behavior captured in video, leading to more accurate and context-aware code generation. Replay understands the intent behind the actions, not just the visual representation.

What types of videos can Replay process?#

Replay can process screen recordings in various formats (MP4, MOV, etc.). The quality of the video will impact the accuracy of the code generation. Clear, well-lit recordings with minimal distractions are recommended.

What frameworks and languages does Replay support?#

Currently, Replay primarily supports React and TypeScript. Support for other frameworks and languages is planned for future releases.

How secure is my video data?#

Replay takes data security seriously. All uploaded videos are encrypted and stored securely. You have complete control over your data and can delete it at any time.


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