A modern, feature-rich nested comment system built with Next.js 15, TypeScript, Clerk authentication, and stunning Framer Motion animations. Experience Reddit-style nested discussions with an elegant, responsive UI.
- π Authentication: Seamless Clerk integration with modal sign-in/sign-up
- π¬ Nested Comments: Reddit-style nested threading with "Continue thread" UI (max 3 levels)
- π Upvote System: Toggle upvotes with smooth animations
- π Sorting Options: Sort by newest, oldest, or most upvoted
- π¨ Smooth Animations: Framer Motion powered micro-interactions and transitions
- π€ User Profiles: View user details, avatar, join date, and all their posts
- βοΈ Rich Post Creation: Create posts with titles, content, and optional cover images
- π― Admin Features: Admin users can delete any post/comment with permission checks
- π± Fully Responsive: Mobile-first design with horizontal scroll protection
- π Dark Mode: Beautiful dark/light theme with next-themes
- π Optimized Performance: Lazy-loading replies, user caching, and efficient rendering
- π Beautiful Hero: Animated landing page with infinite slider and blur effects
pnpm installCreate .env file in the root directory:
# Backend API
NEXT_PUBLIC_BACKEND_URL=https://your-backend-url.com
# Clerk Authentication (get from https://dashboard.clerk.com)
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_xxxxx
CLERK_SECRET_KEY=sk_test_xxxxx
# Clerk Redirect URLs
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=/- Go to Clerk Dashboard β Webhooks
- Add endpoint:
https://your-backend-url.com/clerk-webhook - Subscribe to events:
user.created,user.updated,user.deleted - Copy the signing secret to your backend
.envasCLERK_WEBHOOK_SECRET
pnpm devOpen http://localhost:3000 π
- Beautiful animated hero section with call-to-action buttons
- Infinite slider showcasing powered-by logos
- Progressive blur effects for polished design
- Responsive layout for all screen sizes
- Create Posts: Rich text editor with title, body, and optional image URL
- Post Feed: Grid layout displaying recent posts with author info and comment counts
- Post Details: Full post view with cover image, author details, and nested comments
- User Posts: Profile page showing all posts by a specific user
- Nested Threading: Up to 3 levels of nesting with visual hierarchy
- Continue Thread: Reddit-style "Continue thread" button at max depth
- Lazy Loading: Replies load on demand to optimize performance
- Real-time Upvotes: Animated upvote button with instant feedback
- Reply Count: Shows total nested reply count for each comment
- Sorting: Sort comments by newest, oldest, or most upvoted
- Delete Protection: Only owners and admins can delete comments
- Auto-sync: Clerk users automatically sync to backend database
- User Cache: Efficient caching system for user data
- Profile Page: View user avatar, email, join date, and post count
- Admin Badge: Visual indicator for admin users
- Framer Motion: Smooth animations for comments, posts, and interactions
- Scroll Areas: Radix UI scroll areas with horizontal overflow protection
- Skeleton Loaders: Polished loading states for better UX
- Dropdown Menus: Context menus for comment actions
- Responsive Header: Fixed header with scroll effects and mobile menu
- Theme Switcher: Fixed bottom-right theme toggle button
app/
page.tsx # Landing hero page
layout.tsx # Root layout with Clerk & theme providers
globals.css # Global styles (Tailwind v4)
(main)/ # Main app routes
layout.tsx # Inner layout with footer
recent-posts/ # Post feed page
post/[id]/ # Individual post detail page
profile/ # User profile page
create-post/ # New post creation page
sign-in/ # Clerk sign-in page
sign-up/ # Clerk sign-up page
components/
header.tsx # Animated header with navigation
hero-section.tsx # Landing page hero
theme-switcher.tsx # Dark/light mode toggle
comments/
CommentList.tsx # Main comment list with sorting
Comment.tsx # Individual comment with nested replies
CommentForm.tsx # Comment/reply form
post/
PostCard.tsx # Post card component
PostCardSkeleton.tsx # Loading skeleton
ui/ # Shadcn components
lib/
api.ts # API client with backend integration
types.ts # TypeScript type definitions
userCache.ts # User data caching utility
date-utils.ts # Date formatting helpers
hooks/
useUserSync.ts # Clerk β Backend sync hook
- Next.js 15: App Router with Turbopack for blazing fast development
- React 19: Latest React features
- TypeScript 5: Type-safe development
- Clerk: Complete user authentication with webhooks
- Clerk Themes: Styled authentication UI
- Tailwind CSS v4: Latest Tailwind with CSS-first configuration
- Shadcn UI: Beautiful, accessible component library
- Radix UI: Unstyled, accessible primitives
- next-themes: Dark/light mode theming
- Framer Motion 12: Advanced animations and micro-interactions
- GSAP 3: Professional animation library
- Lucide React: Modern icon library
- Geist Font: Beautiful typography
- CVA: Class variance authority for component variants
- ESLint: Code linting
- PostCSS: CSS processing
- tw-animate-css: Additional Tailwind animations
To grant admin privileges:
- Go to Clerk Dashboard
- Navigate to Users β Select the user
- Go to Metadata tab β Public metadata
- Add the following JSON:
{
"role": "admin"
}- The role will sync to the backend via webhook
- Admin users can now delete any post/comment and see admin badges
- β Verify Clerk webhook is configured correctly
- β
Check
CLERK_WEBHOOK_SECRETin backend.env - β Ensure backend server is accessible from Clerk
- β Check backend logs for webhook events
- β
Verify
NEXT_PUBLIC_BACKEND_URLin.env.local - β Ensure backend server is running
- β Check browser console for API errors
- β Verify CORS is configured on backend
- β Use direct image URLs (not HTML pages)
- β Check CORS settings for external images
- β Verify image URL is accessible
- β
Next.js may need
remotePatternsconfig for external domains
- β
Ensure
suppressHydrationWarningis on<html>tag - β
Check
ThemeProvideris wrapping your app - β Clear browser cache and reload
- Push your code to GitHub
- Import project to Vercel
- Add environment variables in Vercel dashboard:
NEXT_PUBLIC_BACKEND_URLNEXT_PUBLIC_CLERK_PUBLISHABLE_KEYCLERK_SECRET_KEY- Clerk redirect URLs
- Deploy! π
Ensure your backend is deployed and accessible. Update webhook URL in Clerk Dashboard to point to production backend.
The frontend integrates with a backend API. See backend-integration-guide.md for complete API documentation including:
- User management endpoints
- Post CRUD operations
- Comment system with nesting
- Upvote functionality
- Admin operations
- Webhook handling
- β Clerk authentication with secure tokens
- β Permission checks for delete operations
- β Soft deletion (data preserved)
- β User-owned content protection
- β Admin role verification via Clerk metadata
- Smooth Transitions: All page transitions and component animations
- Responsive Grid: Adaptive layouts for mobile, tablet, and desktop
- Skeleton Loaders: Professional loading states
- Hover Effects: Subtle hover animations on interactive elements
- Scroll Indicators: Visual feedback on scrollable content
- Toast Notifications: Error and success messages (ready to implement)
MIT License - Feel free to use this project for personal or commercial purposes.
Built with β€οΈ using:
@CoHub - A modern nested comment system for the web π