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
πš‚πšŠπšžπš›πšŠπš‹πš‘ πšπšŠπš’ β€’

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

Collapse
Β 
envitab profile image
Ekemini Samuel CopilotKit β€’

Thank you, Saurabh! Yes, next is v2 😎

Collapse
Β 
nevodavid profile image
Nevo David CopilotKit β€’

This is really cool!

Collapse
Β 
envitab profile image
Ekemini Samuel CopilotKit β€’

Thank you :)

Collapse
Β 
saikiran76 profile image
Korada Saikiran β€’

Interesting tech stack and really cool 🀠

Collapse
Β 
envitab profile image
Ekemini Samuel CopilotKit β€’

Thank you Korada

Collapse
Β 
resiwicaksono98 profile image
Resi Wicaksono β€’

hmmmm

Collapse
Β 
uliyahoo profile image
uliyahoo CopilotKit β€’

Wow, awesome work!

Collapse
Β 
envitab profile image
Ekemini Samuel CopilotKit β€’

Thank youu!

Collapse
Β 
luis_prott profile image
Luis Prott β€’

v0 as in Vercel's v0?

Collapse
Β 
envitab profile image
Ekemini Samuel CopilotKit β€’

Yes, Vercel's v0

Collapse
Β 
thomas123 profile image
Thomas β€’

Nice

Collapse
Β 
envitab profile image
Ekemini Samuel CopilotKit β€’

Thank you!

Collapse
Β 
shuttle_dev profile image
Shuttle β€’

Awesome work!

Collapse
Β 
envitab profile image
Ekemini Samuel CopilotKit β€’

Thank you team Shuttle!

Collapse
Β 
zack-123 profile image
Sayeed β€’

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

Collapse
Β 
envitab profile image
Ekemini Samuel CopilotKit β€’

Yep, it works.

Collapse
Β 
androaddict profile image
androaddict β€’

Worth to read . Expecting more advance

Collapse
Β 
envitab profile image
Ekemini Samuel CopilotKit β€’

Thank you, yes more implementations of CopilotKit are coming.

Collapse
Β 
fernandezbaptiste profile image
Bap β€’

Really really cool! 😎

Collapse
Β 
envitab profile image
Ekemini Samuel CopilotKit β€’

Thank you :)

Collapse
Β 
the_greatbonnie profile image
Bonnie CopilotKit β€’

Great work, Samuel.

Collapse
Β 
envitab profile image
Ekemini Samuel CopilotKit β€’

Thank you, Bonnie.

Collapse
Β 
ricardogesteves profile image
Ricardo Esteves β€’ β€’ Edited

Niceee, Looks good!! Good job πŸ‘Œ

Collapse
Β 
envitab profile image
Ekemini Samuel CopilotKit β€’

Thank you, Ricardo.

Collapse
Β 
andrew_osada profile image
Andrew β€’

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

Collapse
Β 
envitab profile image
Ekemini Samuel CopilotKit β€’

It took some work though :)

Collapse
Β 
gheeks profile image
Gheek Magossi β€’

Amazing!

Collapse
Β 
envitab profile image
Ekemini Samuel CopilotKit β€’

Thank you!

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 CopilotKit β€’

Thank you, William!

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 CopilotKit β€’

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 CopilotKit β€’

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 CopilotKit β€’

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 CopilotKit β€’

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 CopilotKit β€’

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 CopilotKit β€’

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