Back to Blog
January 8, 20268 min readVue Composition API

Vue Composition API UIs from Video Examples

R
Replay Team
Developer Advocates

TL;DR: Replay empowers developers to rapidly prototype Vue Composition API UIs by automatically generating code from video recordings of desired application behavior.

The promise of AI-powered code generation is tantalizing, but the reality often falls short. Screenshot-to-code tools offer a limited solution, capturing only a static view of the UI. They miss the crucial element: user behavior. What if you could capture the essence of a UI interaction and translate it directly into working code? That's the problem Replay solves. By analyzing video recordings, Replay understands what a user is trying to achieve, not just what they see. This "Behavior-Driven Reconstruction" approach opens up new possibilities for rapid prototyping and UI development, especially when combined with the power of the Vue Composition API.

From Video to Vue: Reconstructing UIs with Replay#

The Vue Composition API offers a more organized and reusable approach to building Vue components compared to the Options API. However, setting up complex state management and reactivity can still be time-consuming. Replay accelerates this process by analyzing video demonstrations of the desired UI behavior and generating the corresponding Vue Composition API code.

Understanding Behavior-Driven Reconstruction#

Traditional screenshot-to-code tools are limited by their reliance on static images. They can generate basic UI elements, but they lack the context of user interactions and application logic. Replay takes a different approach. It analyzes video recordings to understand the sequence of user actions, state changes, and UI updates. This "behavior-driven" approach allows Replay to generate more complete and functional code, including:

  • Event handlers (e.g.,
    text
    onClick
    ,
    text
    onSubmit
    )
  • State management (using
    text
    ref
    and
    text
    reactive
    )
  • Data binding (using
    text
    v-model
    )
  • Conditional rendering (using
    text
    v-if
    and
    text
    v-for
    )
  • API calls and data fetching

Key Features of Replay for Vue Development#

Replay offers several features that are particularly useful for Vue developers:

  • Multi-page Generation: Capture entire user flows across multiple pages and Replay will generate the corresponding Vue components and routing logic.
  • Supabase Integration: Seamlessly integrate your generated Vue code with Supabase for backend services, including authentication, data storage, and real-time updates.
  • Style Injection: Replay can infer styling from the video and inject CSS or Tailwind CSS directly into your Vue components.
  • Product Flow Maps: Visualize the generated code as a product flow map, making it easier to understand the overall application structure.

Practical Example: Building a Simple To-Do List#

Let's walk through a practical example of using Replay to build a simple to-do list application using the Vue Composition API.

Step 1: Record a Video Demonstration#

First, record a video of yourself interacting with a to-do list application. This could be an existing application or a simple prototype you create. Make sure to 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.

The more clearly you demonstrate these actions in the video, the better Replay will be able to understand your intent.

Step 2: Upload the Video to Replay#

Next, upload the video to Replay. Replay will analyze the video and generate the corresponding Vue Composition API code.

Step 3: Review and Refine the Generated Code#

Once Replay has finished analyzing the video, you can review the generated code. Replay provides a visual interface for inspecting the generated components, state management, and event handlers. You can also make manual adjustments to the code as needed.

Here's an example of the code that Replay might generate for a to-do list component:

typescript
// Generated by Replay import { ref, reactive, onMounted } from 'vue'; export default { setup() { const todos = ref([]); const newTodo = ref(''); const addTodo = () => { if (newTodo.value.trim() !== '') { todos.value.push({ id: Date.now(), text: newTodo.value.trim(), completed: false, }); newTodo.value = ''; } }; const toggleComplete = (id: number) => { todos.value = todos.value.map((todo) => todo.id === id ? { ...todo, completed: !todo.completed } : todo ); }; const deleteTodo = (id: number) => { todos.value = todos.value.filter((todo) => todo.id !== id); }; // Example using onMounted to load data from local storage onMounted(() => { const storedTodos = localStorage.getItem('todos'); if (storedTodos) { todos.value = JSON.parse(storedTodos); } }); // Example of watching the todos array and saving to local storage watch( todos, (newTodos) => { localStorage.setItem('todos', JSON.stringify(newTodos)); }, { deep: true } ); return { todos, newTodo, addTodo, toggleComplete, deleteTodo, }; }, };

💡 Pro Tip: For best results, ensure your video is clear, well-lit, and focuses directly on the UI interactions. Minimize distractions in the background.

Step 4: Integrate the Generated Code into Your Vue Application#

Finally, integrate the generated code into your Vue application. You can copy and paste the code directly into your Vue components or use Replay's integration features to automatically deploy the code to your project.

Replay vs. Traditional Code Generation Tools#

Here's a comparison of Replay with traditional code generation tools:

FeatureScreenshot-to-CodeLow-Code PlatformsReplay
InputStatic ImagesDrag-and-Drop UIVideo
Behavior AnalysisLimited
Code QualityBasicOften ComplexHigh
CustomizationLimitedModerateHigh
Learning CurveLowModerateLow
Vue Composition API SupportLimitedVariesExcellent

⚠️ Warning: While Replay significantly accelerates development, it's crucial to review and understand the generated code. Blindly deploying code without understanding its functionality can lead to unexpected issues.

Advanced Use Cases: Beyond the Basics#

Replay can also be used for more advanced use cases, such as:

  • Prototyping Complex UIs: Quickly prototype complex UIs with intricate interactions and state management.
  • Reverse Engineering Existing Applications: Generate code from video recordings of existing applications to understand their functionality and architecture.
  • Creating UI Component Libraries: Generate reusable UI components from video demonstrations.
  • Automating UI Testing: Use Replay to generate UI tests based on video recordings of user interactions.

Integrating with Supabase#

Replay's integration with Supabase allows you to quickly build full-stack Vue applications. You can use Replay to generate the Vue front-end code and Supabase to handle the backend logic, including authentication, data storage, and real-time updates.

Here's an example of how you might integrate the to-do list application with Supabase:

typescript
// Generated by Replay (with Supabase Integration) import { ref, reactive, onMounted } from 'vue'; import { createClient } from '@supabase/supabase-js'; const supabaseUrl = 'YOUR_SUPABASE_URL'; const supabaseKey = 'YOUR_SUPABASE_ANON_KEY'; const supabase = createClient(supabaseUrl, supabaseKey); export default { setup() { const todos = ref([]); const newTodo = ref(''); const loadTodos = async () => { const { data, error } = await supabase .from('todos') .select('*') .order('created_at', { ascending: false }); if (error) { console.error('Error loading todos:', error); } else { todos.value = data; } }; const addTodo = async () => { if (newTodo.value.trim() !== '') { const { data, error } = await supabase .from('todos') .insert([{ text: newTodo.value.trim(), completed: false }]); if (error) { console.error('Error adding todo:', error); } else { todos.value.unshift(data[0]); // Prepend the new todo newTodo.value = ''; } } }; const toggleComplete = async (id: number, completed: boolean) => { const { error } = await supabase .from('todos') .update({ completed: !completed }) .eq('id', id); if (error) { console.error('Error updating todo:', error); } else { todos.value = todos.value.map((todo) => todo.id === id ? { ...todo, completed: !completed } : todo ); } }; const deleteTodo = async (id: number) => { const { error } = await supabase.from('todos').delete().eq('id', id); if (error) { console.error('Error deleting todo:', error); } else { todos.value = todos.value.filter((todo) => todo.id !== id); } }; onMounted(loadTodos); return { todos, newTodo, addTodo, toggleComplete, deleteTodo, }; }, };

📝 Note: Remember to replace

text
YOUR_SUPABASE_URL
and
text
YOUR_SUPABASE_ANON_KEY
with your actual Supabase credentials.

Styling with Replay#

Replay can also infer styling from the video and inject CSS or Tailwind CSS directly into your Vue components. This can save you a significant amount of time and effort when building UIs.

Replay analyzes the visual elements in the video, such as colors, fonts, and spacing, and generates the corresponding CSS rules. You can then customize these rules to match your desired design.

Frequently Asked Questions#

Is Replay free to use?#

Replay offers a free tier with limited usage. Paid plans are available for more advanced features and higher usage limits. Check the Replay website for the most up-to-date pricing information.

How is Replay different from v0.dev?#

While both tools aim to accelerate UI development, Replay distinguishes itself through its "Behavior-Driven Reconstruction" approach. V0.dev, and similar tools, often rely on text prompts and pre-defined components. Replay analyzes video to understand user intent and application logic, resulting in more accurate and functional code generation, especially for complex interactions. Replay captures the "how" of the interaction, not just the "what" of the desired outcome.

What types of videos work best with Replay?#

Videos with clear UI interactions, good lighting, and minimal distractions work best. Ensure the video focuses on the specific UI elements and actions you want to reconstruct.

Can Replay generate code for other frameworks besides Vue?#

Currently, Replay primarily focuses on Vue.js. Support for other frameworks is planned for future releases.


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