Back to Blog
January 17, 20268 min readGenerating a News

Generating a News Website UI from a Video Demonstration

R
Replay Team
Developer Advocates

TL;DR: Learn how to use Replay to automatically generate a working news website UI from a simple video demonstration, complete with Supabase integration and style injection.

Generating UIs from static mockups is old news. The real challenge is capturing the intent behind user interactions and translating that into functional code. That's where video-to-code comes in, and Replay is leading the charge. Forget screenshot-to-code tools that only understand what's on the screen. Replay analyzes the behavior within the video, leveraging Gemini to reconstruct a fully functional UI. Let's dive into generating a news website UI from a video demonstration.

Why Video-to-Code is the Future#

The traditional UI development process involves multiple steps: design mockups, prototypes, manual coding, and iterative refinements. This process is time-consuming and prone to errors. Video-to-code offers a streamlined alternative, particularly when powered by behavior-driven reconstruction.

Here's how Replay changes the game:

  • Captures User Intent: Replay analyzes the video to understand user actions, not just the visual elements.
  • Automated Code Generation: Generates clean, maintainable code directly from the video.
  • Rapid Prototyping: Quickly create functional prototypes to test and iterate on ideas.
  • Reduced Development Time: Significantly cuts down on manual coding efforts.

Building a News Website UI from Video: A Step-by-Step Guide#

Let's walk through the process of generating a news website UI using Replay. Imagine you have a screen recording demonstrating the desired layout, navigation, and article display.

Step 1: Preparing the Video#

The quality of the video directly impacts the accuracy of the generated code. Here are some tips:

  • Clear Visuals: Ensure the video is well-lit and the UI elements are easily visible.
  • Smooth Interactions: Demonstrate interactions smoothly and deliberately.
  • Consistent Style: Maintain a consistent visual style throughout the demonstration.
  • Minimal Distractions: Avoid unnecessary mouse movements or background noise.

📝 Note: Replay works best with videos showcasing a single, well-defined user flow. Keep the demo focused.

Step 2: Uploading and Processing the Video in Replay#

Upload your video to Replay. The platform will automatically process the video, analyzing the UI elements and user interactions. This process involves:

  1. Frame Extraction: Extracting individual frames from the video.
  2. UI Element Detection: Identifying and classifying UI elements (buttons, text fields, images, etc.).
  3. Behavior Analysis: Analyzing user interactions (clicks, scrolls, form inputs) to understand the intended behavior.
  4. Code Generation: Generating the corresponding code based on the analyzed data.

Step 3: Reviewing and Refining the Generated Code#

Once the processing is complete, Replay presents the generated code. This code typically includes:

  • HTML: Structure of the news website layout.
  • CSS: Styling for the UI elements.
  • JavaScript: Functionality for user interactions.

Review the code carefully and make any necessary adjustments. Replay allows you to edit the generated code directly within the platform.

💡 Pro Tip: Pay close attention to the semantic HTML generated. Replay attempts to use appropriate tags (e.g.,

text
<article>
,
text
<nav>
,
text
<aside>
) for better SEO and accessibility.

Step 4: Integrating with Supabase (Optional)#

For a dynamic news website, you'll need a backend database to store and manage articles. Replay offers seamless integration with Supabase, a popular open-source Firebase alternative.

Here's how to integrate Supabase:

  1. Set up Supabase: Create a Supabase project and define the necessary tables for storing articles (e.g.,
    text
    articles
    table with columns like
    text
    title
    ,
    text
    content
    ,
    text
    author
    ,
    text
    date
    ).
  2. Configure Replay: Connect your Replay project to your Supabase project by providing the Supabase URL and API key.
  3. Generate API Calls: Replay can automatically generate API calls to fetch and display articles from Supabase.

Here's an example of a JavaScript function generated by Replay to fetch articles from Supabase:

typescript
// Fetch articles from Supabase const fetchArticles = async () => { const { data, error } = await supabase .from('articles') .select('*') .order('date', { ascending: false }); if (error) { console.error('Error fetching articles:', error); return []; } return data; };

This function uses the Supabase client library to query the

text
articles
table, retrieve all articles, and sort them by date in descending order.

Step 5: Injecting Custom Styles#

Replay allows you to inject custom CSS styles to fine-tune the appearance of your news website. You can either add inline styles directly within the HTML code or create a separate CSS file and link it to your project.

⚠️ Warning: Overriding the generated CSS styles can sometimes lead to unexpected results. Be sure to test your changes thoroughly.

Here's an example of injecting custom styles to change the font and color of the article titles:

css
.article-title { font-family: 'Arial', sans-serif; color: #333; }

Step 6: Product Flow Maps#

Replay automatically generates product flow maps from the video analysis. These maps visualize the user's journey through the news website, highlighting key interactions and navigation paths. This helps you understand how users are likely to interact with your site and identify potential areas for improvement.

Replay vs. Traditional Methods and Other Tools#

Let's compare Replay with traditional UI development methods and other code generation tools.

FeatureTraditional MethodScreenshot-to-CodeReplay
InputDesign mockups, prototypesScreenshotsVideo
Understanding User IntentManual analysisLimitedHigh
Code QualityDepends on developer skillBasicGood
Time to PrototypeHighMediumLow
Supabase IntegrationManualManualAutomated
Behavior AnalysisManualLimitedComprehensive
Multi-page GenerationManualManual

As you can see, Replay offers several advantages over traditional methods and other code generation tools. Its ability to analyze video and understand user intent results in higher-quality code and faster prototyping.

Here's a comparison with similar tools:

Featurev0.devTeleportHQReplay
Video Input
Behavior AnalysisPartial
Code QualityHighMediumGood
Learning CurveLowMediumLow
PricingPaidFreemiumPaid

Replay stands out with its video input and behavior analysis capabilities, making it a powerful tool for generating functional UIs from real-world demonstrations.

Benefits of Using Replay for UI Development#

Using Replay for UI development offers several benefits:

  • Accelerated Development: Generate functional UIs in a fraction of the time compared to traditional methods.
  • Improved Code Quality: Replay generates clean, maintainable code that adheres to best practices.
  • Enhanced Collaboration: Easily share video demonstrations and generated code with your team.
  • Data-Driven Design: Use product flow maps to understand user behavior and optimize your UI.
  • Reduced Costs: Lower development costs by automating code generation.

Code Example: Displaying Articles on the News Website#

Here's an example of how to display articles fetched from Supabase on the news website, using JavaScript and HTML generated (and potentially refined) by Replay:

html
<!DOCTYPE html> <html> <head> <title>News Website</title> <link rel="stylesheet" href="style.css"> </head> <body> <div class="container"> <h1>Latest News</h1> <div id="articles-container"> <!-- Articles will be displayed here --> </div> </div> <script> const articlesContainer = document.getElementById('articles-container'); // Function to display articles const displayArticles = (articles) => { articles.forEach(article => { const articleElement = document.createElement('div'); articleElement.classList.add('article'); const titleElement = document.createElement('h2'); titleElement.classList.add('article-title'); titleElement.textContent = article.title; const contentElement = document.createElement('p'); contentElement.classList.add('article-content'); contentElement.textContent = article.content; articleElement.appendChild(titleElement); articleElement.appendChild(contentElement); articlesContainer.appendChild(articleElement); }); }; // Fetch and display articles fetchArticles() .then(articles => { displayArticles(articles); }); </script> </body> </html>

This code fetches articles using the

text
fetchArticles
function (defined previously) and dynamically creates HTML elements to display each article on the page. The styling is handled by the
text
style.css
file, which Replay can also help generate based on the video.

Frequently Asked Questions#

Is Replay free to use?#

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

How is Replay different from v0.dev?#

Replay uniquely uses video as input, allowing it to understand user behavior and generate more functional and context-aware code than v0.dev, which relies on text prompts. Replay also offers features like Supabase integration and product flow maps.

What types of videos work best with Replay?#

Videos that clearly demonstrate a single, well-defined user flow with consistent visual styles tend to produce the best results.

Can Replay generate code for complex UI interactions?#

Yes, Replay can handle complex UI interactions, including form submissions, animations, and dynamic content updates. The accuracy of the generated code depends on the clarity and detail of the video demonstration.

What frameworks does Replay support?#

Replay supports a variety of popular front-end frameworks, including React, Vue.js, and Angular. Check the Replay documentation for the latest supported frameworks.


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