A modern, full-featured Discord clone built with Next.js 15, featuring real-time messaging, voice channels, server management, and more. This application replicates the core functionality of Discord with a clean, responsive interface.
- Secure Authentication with Clerk integration
- User Profiles with customizable avatars and display names
- Protected Routes with middleware-based authentication
- Create & Join Servers with unique invite codes
- Server Customization with custom names and images
- Member Management with role-based permissions (Admin, Moderator, Guest)
- Server Settings and moderation tools
- Text Channels with live messaging via Socket.IO
- Direct Messages between server members
- File Sharing with support for images, PDFs, videos, and audio
- Emoji Support with emoji picker integration
- Message History with persistent storage
- Text Channels for messaging and file sharing
- Audio Channels for voice communication (planned)
- Video Channels for video calls (planned)
- Dark/Light Theme toggle with system preference detection
- Responsive Design optimized for desktop and mobile
- Real-time Status Indicators showing connection status
- Intuitive Navigation with collapsible sidebars
- Modal-based Interactions for seamless user experience
- Next.js 15.3.4 - React framework with App Router
- React 19 - UI library with latest features
- TypeScript 5.x - Type-safe development
- Tailwind CSS 4.1.10 - Utility-first CSS framework
- Radix UI - Accessible component primitives
- PostgreSQL 15 - Primary database
- Prisma 6.12.0 - Database ORM and migrations
- Socket.IO - Real-time bidirectional communication
- Clerk - Authentication and user management
- UploadThing - File upload and storage service
- Zustand 5.0.6 - Lightweight state management
- React Hook Form 7.58.1 - Performant forms
- Zod 3.25.67 - Schema validation
Before you begin, ensure you have the following installed:
- Node.js (version 18.0 or higher)
- npm (version 8.0 or higher) or yarn (version 1.22 or higher)
- PostgreSQL (version 15 or higher)
- Git for version control
- Clerk account for authentication
- UploadThing account for file uploads
- PostgreSQL database (local or hosted, e.g., Supabase, Railway, PlanetScale)
git clone https://github.com/yourusername/discord-clone.git
cd discord-clonenpm install
# or
yarn install# Start PostgreSQL container
docker-compose up -d
# The database will be available at:
# Host: localhost
# Port: 5432
# Database: discord_clone
# Username: discord_user
# Password: your_secure_passwordEnsure PostgreSQL is running and create a database:
CREATE DATABASE discord_clone;Create a .env.local file in the root directory:
# Database
DATABASE_URL="postgresql://discord_user:your_secure_password@localhost:5432/discord_clone"
DIRECT_URL="postgresql://discord_user:your_secure_password@localhost:5432/discord_clone"
# Clerk Authentication
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key
CLERK_SECRET_KEY=your_clerk_secret_key
NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in
NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up
NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=/
NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/
# UploadThing
UPLOADTHING_SECRET=your_uploadthing_secret
UPLOADTHING_APP_ID=your_uploadthing_app_id
# Application
NEXT_PUBLIC_SITE_URL=http://localhost:3000# Generate Prisma client
npx prisma generate
# Run database migrations
npx prisma db push
# (Optional) Seed the database
npx prisma db seednpm run dev
# or
yarn devOpen http://localhost:3000 in your browser to see the application.
# Development server with Turbopack
npm run dev
# Production build
npm run build
# Start production server
npm run start
# Lint code
npm run lint
# Database operations
npx prisma studio # Open Prisma Studio
npx prisma db push # Push schema changes
npx prisma generate # Generate Prisma client
npx prisma migrate dev # Create and apply migrations- Hot Reload - Changes are reflected instantly
- Turbopack - Fast bundler for development
- TypeScript - Real-time type checking
- ESLint - Code quality and consistency
discord-clone/
βββ app/ # Next.js App Router
β βββ (auth)/ # Authentication routes (grouped)
β β βββ (routes)/ # Sign-in/Sign-up pages
β β βββ layout.tsx # Auth layout
β βββ (invite)/ # Server invite handling
β βββ (main)/ # Main application routes
β β βββ (routes)/ # Server and channel pages
β β βββ layout.tsx # Main app layout
β βββ (setup)/ # Initial user setup
β βββ api/ # API routes
β β βββ channels/ # Channel management
β β βββ members/ # Member management
β β βββ servers/ # Server operations
β β βββ uploadthing/ # File upload handling
β βββ globals.css # Global styles
β βββ layout.tsx # Root layout
βββ components/ # React components
β βββ chat/ # Chat-related components
β βββ modals/ # Modal dialogs
β βββ navigations/ # Navigation components
β βββ providers/ # Context providers
β βββ server/ # Server-specific UI
β βββ ui/ # Reusable UI components
βββ hooks/ # Custom React hooks
βββ lib/ # Utility libraries
β βββ db.ts # Database connection
β βββ utils.ts # Helper functions
β βββ uploadthing.ts # File upload utilities
βββ pages/api/socket/ # Socket.IO API routes
βββ prisma/ # Database schema and migrations
β βββ migrations/ # Database migrations
β βββ schema.prisma # Database schema
βββ public/ # Static assets
βββ types.ts # TypeScript type definitions
| Variable | Description | Example |
|---|---|---|
DATABASE_URL |
PostgreSQL connection string | postgresql://user:pass@localhost:5432/db |
DIRECT_URL |
Direct database connection (for migrations) | Same as DATABASE_URL |
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY |
Clerk public key | pk_test_... |
CLERK_SECRET_KEY |
Clerk secret key | sk_test_... |
UPLOADTHING_SECRET |
UploadThing secret key | sk_live_... |
UPLOADTHING_APP_ID |
UploadThing application ID | your-app-id |
NEXT_PUBLIC_SITE_URL |
Application URL | http://localhost:3000 |
| Variable | Description | Default |
|---|---|---|
NEXT_PUBLIC_CLERK_SIGN_IN_URL |
Sign-in page URL | /sign-in |
NEXT_PUBLIC_CLERK_SIGN_UP_URL |
Sign-up page URL | /sign-up |
NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL |
Redirect after sign-in | / |
NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL |
Redirect after sign-up | / |
- Create account at clerk.com
- Create new application
- Copy API keys to your
.env.local - Configure redirect URLs in Clerk dashboard
- Create account at uploadthing.com
- Create new application
- Copy API keys to your
.env.local - Configure file size limits and allowed types
| Platform | Database | Setup |
|---|---|---|
| Vercel β | Supabase | Connect GitHub β Add env vars β Deploy |
| Railway | Built-in PostgreSQL | One-click deploy from GitHub |
| Netlify | PlanetScale | Build: npm run build, Dir: .next |
- Build locally:
npm run build(ensure no errors) - Environment variables: Copy all from
.env.localto your platform - Database: Set up PostgreSQL and run migrations
- Domain: Update
NEXT_PUBLIC_SITE_URLto your production URL - Test: Verify authentication and file uploads work
We welcome contributions to the Discord Clone project! Here's how you can help:
- Fork the repository
- Clone your fork:
git clone https://github.com/yourusername/discord-clone.git
- Create a feature branch:
git checkout -b feature/amazing-feature
- Make your changes and commit:
git commit -m 'Add some amazing feature' - Push to your branch:
git push origin feature/amazing-feature
- Open a Pull Request
- Code Style: Follow the existing code style and use ESLint
- TypeScript: Maintain type safety throughout the codebase
- Testing: Add tests for new features (when test suite is available)
- Documentation: Update documentation for significant changes
- Commits: Use clear, descriptive commit messages
- π΅ Voice/Video Chat - WebRTC integration for audio/video channels
- π Advanced Permissions - Granular role-based permissions
- π¨ UI/UX Improvements - Enhanced user interface and experience
- π± Mobile Optimization - Better mobile responsiveness
- π Search Functionality - Message and server search
- π€ Bot Integration - Discord bot support
- π Internationalization - Multi-language support
- β‘ Performance - Optimization and caching improvements
When reporting issues, please include:
- Environment details (OS, Node.js version, browser)
- Steps to reproduce the issue
- Expected vs actual behavior
- Screenshots if applicable
- Error messages from console/logs
This project is licensed under the MIT License - see the LICENSE file for details.
Key points:
- β Commercial use allowed
- β Modification allowed
- β Distribution allowed
- β Private use allowed
- β No warranty provided
- β No liability assumed
- π Documentation: Check this README and inline code comments
- π Issues: Report bugs and request features via GitHub Issues
- π¬ Discussions: Ask questions and share ideas in GitHub Discussions
- π Code Examples: Review the codebase for implementation details
- Stack Overflow: Tag your questions with
discord-cloneandnextjs - Next.js Community: Next.js Discord for framework-specific help
- React Community: Reactiflux Discord for React questions
- Discord - For the inspiration and design reference
- Vercel - For the amazing Next.js framework and hosting
- Clerk - For seamless authentication
- Prisma - For the excellent database toolkit
- Radix UI - For accessible component primitives
- Tailwind CSS - For the utility-first CSS framework
Made with β€οΈ by the Discord Clone team