DEV Community

Cover image for How to build: a v0.dev clone (Next.js, GPT4 & CopilotKit)

How to build: a v0.dev clone (Next.js, GPT4 & CopilotKit)

Ekemini Samuel on April 04, 2024

TL;DR In this article, you will learn how to build a clone of Vercel's V0.dev. This is an awesome project to add to your portfolio and t...
Collapse
 
srbhr profile image
Saurabh Rai

Wow this is really cool! Now we have v1!!

Collapse
 
envitab profile image
Ekemini Samuel

Thank you, Saurabh! Yes, next is v2 😎

Collapse
 
saikiran76 profile image
Korada Saikiran

Interesting tech stack and really cool 🤠

Collapse
 
envitab profile image
Ekemini Samuel

Thank you Korada

Collapse
 
resiwicaksono98 profile image
Resi Wicaksono

hmmmm

Collapse
 
uliyahoo profile image
uliyahoo

Wow, awesome work!

Collapse
 
envitab profile image
Ekemini Samuel

Thank youu!

Collapse
 
nevodavid profile image
Nevo David

This is really cool!

Collapse
 
envitab profile image
Ekemini Samuel

Thank you :)

Collapse
 
thomas123 profile image
Thomas

Nice

Collapse
 
envitab profile image
Ekemini Samuel

Thank you!

Collapse
 
androaddict profile image
androaddict

Worth to read . Expecting more advance

Collapse
 
envitab profile image
Ekemini Samuel

Thank you, yes more implementations of CopilotKit are coming.

Collapse
 
zack-123 profile image
Zack

If this actually works then it's cool...

Collapse
 
envitab profile image
Ekemini Samuel

Yep, it works.

Collapse
 
john-123 profile image
John

v0 as in Vercel's v0?

Collapse
 
envitab profile image
Ekemini Samuel

Yes, Vercel's v0

Collapse
 
shuttle_dev profile image
Shuttle

Awesome work!

Collapse
 
envitab profile image
Ekemini Samuel

Thank you team Shuttle!

Collapse
 
fernandezbaptiste profile image
Bap

Really really cool! 😎

Collapse
 
envitab profile image
Ekemini Samuel

Thank you :)

Collapse
 
ricardogesteves profile image
Ricardo Esteves • Edited

Niceee, Looks good!! Good job 👌

Collapse
 
envitab profile image
Ekemini Samuel

Thank you, Ricardo.

Collapse
 
the_greatbonnie profile image
Bonnie

Great work, Samuel.

Collapse
 
envitab profile image
Ekemini Samuel

Thank you, Bonnie.

Collapse
 
william4411 profile image
william4411

This looks like a cool walkthrough. Excited to try it out over the weekend.

Collapse
 
envitab profile image
Ekemini Samuel

Thank you, William!

Collapse
 
andrew0123 profile image
Andrew

Didn't think it would be this easy to clone v0!

Collapse
 
envitab profile image
Ekemini Samuel

It took some work though :)

Collapse
 
perriekkola profile image
Per • Edited

A really cool concept, but unfortunately the tutorial code and the repository shared doesn't work as expected. The HTML preview returns a string like "quMXj6KfFLs7gqzeX_UMJ" instead of working HTML/CSS.

The history sidebar doesn't match the one in your own screenshots, so it gets a bit confusing.

If possible, I would suggest that you run through your guide yourself and see if you run into the same problems, since I noticed another user had the same issues as me. I have double-checked the API key as well, no issues there.

Collapse
 
envitab profile image
Ekemini Samuel

Thank you. Please ensure that you run npm install to install all dependencies. Here is the repository:
github.com/Tabintel/v0-copilot-next

Collapse
 
baucucu profile image
Alex Raduca

there is an issue with readableCode defined on line 29 in page.tsx. it returns a string that looks like a unique ID.
I had to replace readableCode with codeToDisplay in JSX to make it work

Thread Thread
 
envitab profile image
Ekemini Samuel

Thank you, Alex. I have updated it with the changes from my local environment. It's now in sync.

Thread Thread
 
baucucu profile image
Alex Raduca

This is awsome! I forked it and I'm working on some minor improvements.
I managed to get a complete component made with gpt 4 turbo but it's not being displayed correctly. The code works however, I just copied it into a component file and rendered it.

Here is the generated code

import React from "react";
import { useState } from "react";
const LoginForm = () => {
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [rememberMe, setRememberMe] = useState(false);
const handleSubmit = (e) => {
e.preventDefault();
console.log({ email, password, rememberMe });
};
return (
<div className="flex items-center justify-center min-h-screen bg-gray-100">
{" "}
<form
className="p-6 bg-white shadow-md rounded-lg"
onSubmit={handleSubmit}
>
{" "}
<h2 className="text-2xl font-semibold text-gray-800 mb-4">
Login
</h2>{" "}
<div className="mb-4">
{" "}
<label
htmlFor="email"
className="block text-gray-700 text-sm font-bold mb-2"
>
Email Address
</label>{" "}
<input
type="email"
id="email"
className="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
value={email}
onChange={(e) => setEmail(e.target.value)}
required
/>{" "}
</div>{" "}
<div className="mb-4">
{" "}
<label
htmlFor="password"
className="block text-gray-700 text-sm font-bold mb-2"
>
Password
</label>{" "}
<input
type="password"
id="password"
className="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 mb-3 leading-tight focus:outline-none focus:shadow-outline"
value={password}
onChange={(e) => setPassword(e.target.value)}
required
/>{" "}
</div>{" "}
<div className="mb-4 flex items-center">
{" "}
<input
type="checkbox"
id="rememberMe"
className="mr-2"
checked={rememberMe}
onChange={(e) => setRememberMe(e.target.checked)}
/>{" "}
<label htmlFor="rememberMe" className="text-sm text-gray-700">
Remember Me
</label>{" "}
</div>{" "}
<button
type="submit"
className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline"
>
Login
</button>{" "}
<div className="mt-4 text-center">
{" "}
<a href="#" className="text-sm text-blue-500 hover:text-blue-700">
Forgot Password?
</a>{" "}
<br />{" "}
<a href="#" className="text-sm text-blue-500 hover:text-blue-700">
Register
</a>{" "}
</div>{" "}
</form>{" "}
</div>
);
};
export default LoginForm;

Image description

Thread Thread
 
envitab profile image
Ekemini Samuel

That's great Alex! I'm glad you tried it out 😎

Have you tried generating other UI components?

Collapse
 
jonathanleahy profile image
Jonathan Leahy

While being incredibly general, the repo didn't work for me. Could you please refine it? The concept looks good.

Collapse
 
envitab profile image
Ekemini Samuel

Thank you, Jonathan. Here is the repo:
github.com/Tabintel/v0-copilot-next

Collapse
 
campbellgoe profile image
George O. E. Campbell

This tutorial neither the shared repository with my API KEY worked... doesn't output code just some random letters numbers.

Collapse
 
envitab profile image
Ekemini Samuel

Hi George, please double-check that the GPT-4 API KEY is entered correctly. Here's the repository:
github.com/Tabintel/v0-copilot-next

Collapse
 
rav291 profile image
Ravi Anand

Are we persisting data by any chance ?

Collapse
 
envitab profile image
Ekemini Samuel

Currently, it's not, that'll involve integrating a database. Let me know if you need help implementing it in your version.