v0 Platform API/Examples
v0 Clone
A full-featured v0 clone with authentication and multi-tenant support
This example demonstrates how to build a complete v0.dev replica using the v0 SDK, featuring user authentication, multi-tenant architecture, and real-time streaming capabilities.
Deploy Your Own
You can deploy your own version of the v0 clone to Vercel with one click:
Features
Core Features
- AI Elements Integration: Uses AI Elements components for a polished UI
- v0 SDK Integration: Connects to the v0 Platform API for generating apps
- Real-time Preview: Split-screen interface with chat and preview panels
- Conversation History: Maintains chat history throughout the session
- Suggestion System: Provides helpful prompts to get users started
- Streaming Support: Toggle between streaming and non-streaming AI responses for real-time updates
Authentication & Multi-Tenant Features
- Anonymous Access: Unauthenticated users can create chats directly (with rate limits)
- Guest Access: Users can register as guests for persistent sessions
- User Registration/Login: Email/password authentication with secure password hashing
- Session Management: Secure session handling with NextAuth.js
- Multi-Tenant Architecture: Multiple users share the same v0 API organization
- Ownership Mapping: Authenticated users only see their own chats and projects
- Rate Limiting: Different limits for anonymous, guest, and registered users
- User Navigation: Header dropdown with user info and sign-out options
Setup
Environment Variables
Create a .env
file with all required variables:
Database Setup
This project uses PostgreSQL with Drizzle ORM. Set up your database:
-
Generate Database Schema:
-
Run Database Migrations:
-
Optional - Open Database Studio:
Getting Started
Then, run the development server:
Open http://localhost:3000 with your browser to see the result.
Architecture
Multi-Tenant Design
- v0 API as Source of Truth: All actual chat/project data stays in v0 API
- Ownership Layer: Database only tracks "who owns what"
- Access Control: API routes filter v0 data based on ownership
- No Data Duplication: Avoids storing redundant data
Database Schema
- Users: Store user accounts with email and hashed passwords
- ProjectOwnership: Maps v0 API project IDs → user IDs (ownership only)
- ChatOwnership: Maps v0 API chat IDs → user IDs with optional project association
- AnonymousChatLog: Tracks anonymous chat creation by IP address for rate limiting
User Types & Rate Limits
- Anonymous Users: No account needed, 3 chats per day, no data persistence
- Guest Users: Auto-created accounts, 5 chats per day, data persists during session
- Registered Users: Permanent accounts, 50 chats per day, data persists across sessions and devices
Rate limits are enforced per 24-hour period and reset daily.
Source Code
View the complete source code on GitHub: v0-sdk/examples/v0-clone