π§΅ Threads β Full-Stack Social Media App
A feature-rich, full-stack social media application inspired by Meta's Threads , built with Next.js 15 , MongoDB , Clerk Authentication , and UploadThing . Users can create threads, reply, like, repost, search for other users, join communities, and more β all wrapped in a sleek dark-themed UI.
π Authentication β Secure sign-up, sign-in, and onboarding flow powered by Clerk with a dark theme.
π Create Threads β Share your thoughts by creating new threads with rich text input.
π¬ Nested Replies β Comment on threads and engage in nested, threaded conversations.
β€οΈ Like Threads β Like and unlike threads with real-time feedback.
π Repost Threads β Repost threads to amplify content you enjoy.
π Share Threads β Share threads via a convenient share button.
ποΈ Delete Threads β Remove your own threads with a confirmation modal.
π Search Users β Discover other users on the platform with the search bar.
π€ User Profiles β View user profiles with profile headers, bio, and tabbed content (Threads, Replies, Tagged).
ποΈ Communities β Browse and join communities with dedicated community pages and member listings.
πΈ Image Uploads β Upload profile images via UploadThing .
π Pagination β Paginated feeds for smooth browsing through threads.
π± Responsive Design β Fully responsive layout with a top bar, left sidebar, right sidebar, and mobile bottom bar.
π Activity Feed β Stay updated with an activity page for notifications.
π Webhooks β Real-time data sync with Clerk via webhook integration (Svix).
π¨ Dark Theme β Beautiful dark-mode interface throughout the entire application.
threads/
βββ app/
β βββ (auth)/ # Authentication pages
β β βββ layout.tsx # Auth layout with dark Clerk theme
β β βββ sign-in/ # Sign-in page
β β βββ sign-up/ # Sign-up page
β β βββ onboarding/ # User onboarding flow
β βββ (root)/ # Main application pages
β β βββ layout.tsx # Root layout (Topbar, Sidebars, Bottombar)
β β βββ page.tsx # Home feed
β β βββ activity/ # Activity / notifications page
β β βββ communities/ # Communities listing & detail pages
β β βββ create-thread/ # Create new thread page
β β βββ profile/[id]/ # User profile page
β β βββ search/ # User search page
β β βββ thread/ # Individual thread page
β βββ api/
β β βββ uploadthing/ # UploadThing API routes
β β βββ webhooks/clerk/ # Clerk webhook handler
β βββ globals.css # Global styles
β βββ favicon.ico
βββ components/
β βββ cards/ # Card components
β β βββ ThreadCard.tsx # Thread display card
β β βββ CommunityCard.tsx # Community display card
β β βββ UserCard.tsx # User display card
β β βββ ThreadLikeButton.tsx # Like interaction button
β β βββ ThreadRepostButton.tsx # Repost interaction button
β β βββ ThreadShareButton.tsx # Share interaction button
β βββ forms/ # Form components
β β βββ AccountProfile.tsx # Profile edit form
β β βββ PostThread.tsx # Create thread form
β β βββ Comment.tsx # Comment/reply form
β β βββ DeleteThread.tsx # Thread deletion handler
β β βββ ConfirmDeleteModal.tsx # Deletion confirmation modal
β βββ shared/ # Shared layout components
β β βββ Topbar.tsx # Top navigation bar
β β βββ LeftSidebar.tsx # Left sidebar navigation
β β βββ RightSidebar.tsx # Right sidebar (suggestions)
β β βββ Bottombar.tsx # Mobile bottom navigation
β β βββ ProfileHeader.tsx # User profile header
β β βββ ThreadsTab.tsx # Threads tab content
β β βββ RepostsTab.tsx # Reposts tab content
β β βββ Searchbar.tsx # Search input component
β β βββ Pagination.tsx # Pagination controls
β β βββ PaginationWrapper.tsx
β βββ ui/ # Radix-based UI primitives
βββ lib/
β βββ actions/ # Server actions
β β βββ thread.actions.ts # Thread CRUD operations
β β βββ user.actions.ts # User CRUD operations
β β βββ community.actions.ts # Community CRUD operations
β βββ models/ # Mongoose models
β β βββ thread.model.ts # Thread schema
β β βββ user.model.ts # User schema
β β βββ community.model.ts # Community schema
β βββ validations/ # Zod validation schemas
β β βββ thread.ts # Thread form validation
β β βββ user.ts # User form validation
β βββ mongoose.ts # MongoDB connection utility
β βββ uploadthing.ts # UploadThing configuration
β βββ utils.ts # Utility functions
βββ constants/
β βββ index.js # Sidebar links, profile & community tabs
βββ public/
β βββ assets/ # SVG icons and assets
β βββ logo.svg # App logo
βββ middleware.ts # Clerk auth middleware
βββ next.config.ts # Next.js configuration
βββ package.json
βββ tsconfig.json
βββ tailwind / postcss configs
git clone https://github.com/ahmednasser111/threads.git
cd threads
yarn install
# or
npm install
3. Set Up Environment Variables
Create a .env.local file in the project root with the following variables:
# Clerk Authentication
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY = pk_test_xxxxx
CLERK_SECRET_KEY = sk_test_xxxxx
NEXT_PUBLIC_CLERK_SIGN_IN_URL = /sign-in
NEXT_PUBLIC_CLERK_SIGN_UP_URL = /sign-up
NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL = /onboarding
NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL = /onboarding
# MongoDB
MONGODB_URI = mongodb+srv://<username>:<password>@cluster.mongodb.net/threads
# UploadThing
UPLOADTHING_SECRET = sk_live_xxxxx
UPLOADTHING_APP_ID = xxxxx
# Clerk Webhook (Svix)
CLERK_WEBHOOK_SECRET = whsec_xxxxx
4. Run the Development Server
yarn dev
# or
npm run dev
Open http://localhost:3000 in your browser to see the app.
Command
Description
yarn dev
Start the development server
yarn build
Build the production application
yarn start
Start the production server
yarn lint
Run ESLint for code quality checks
Field
Type
Description
id
String
Clerk user ID (unique)
username
String
Unique username
name
String
Display name
image
String
Profile image URL
bio
String
User bio (max 500 chars)
threads
ObjectId[]
References to authored threads
onboarded
Boolean
Whether onboarding is completed
communities
ObjectId[]
Communities the user belongs to
Field
Type
Description
text
String
Thread content
author
ObjectId
Reference to the author (User)
community
ObjectId
Reference to a community
createdAt
Date
Timestamp of creation
parentId
String
Parent thread ID (for replies)
likes
String[]
Array of user IDs who liked
reposts
String[]
Array of user IDs who reposted
children
ObjectId[]
References to child threads
Community
Field
Type
Description
id
String
Clerk organization ID
username
String
Unique community handle
name
String
Community display name
image
String
Community image URL
bio
String
Community description
createdBy
ObjectId
Reference to creator (User)
threads
ObjectId[]
References to community threads
members
ObjectId[]
References to community members
Route
Method
Description
/api/uploadthing
POST
Handle file uploads via UploadThing
/api/webhooks/clerk
POST
Handle Clerk webhook events (Svix)
Contributions are welcome! Feel free to open an issue or submit a pull request.
Fork the repository
Create your feature branch (git checkout -b feature/amazing-feature)
Commit your changes (git commit -m 'Add some amazing feature')
Push to the branch (git push origin feature/amazing-feature)
Open a Pull Request
This project is open source and available under the MIT License .