A modern, real-time chat application built with Next.js 16 that creates private, self-destructing chat rooms. Share a room link and chat securely with automatic message deletion after 10 minutes.
- π Private Chat Rooms - Create secure, temporary chat rooms with unique IDs
- β±οΈ Self-Destructing - Rooms automatically expire after 10 minutes
- π₯ User Limits - Configure room capacity (1-20 users)
- β‘ Real-time Messaging - Instant message delivery using Upstash Realtime
- π¨ Modern UI - Beautiful interface with dark/light theme support
- π Theme Colors - Customizable theme colors with smooth transitions
- π£ Manual Destruction - Option to destroy rooms immediately
- π± Responsive Design - Works seamlessly on desktop and mobile devices
- Next.js 16 - React framework with App Router
- React 19 - UI library
- TypeScript - Type safety
- Tailwind CSS 4 - Styling
- shadcn/ui - UI component library
- TanStack Query - Data fetching and state management
- React Hook Form - Form handling
- Zod - Schema validation
- Elysia.js - Fast web framework for API routes
- Upstash Redis - Serverless Redis for data persistence
- Upstash Realtime - Real-time pub/sub messaging
- Eden Treaty - Type-safe API client
- Node.js 18+ or Bun runtime
- Upstash Account - For Redis and Realtime services
- Create a Redis database at Upstash Console
- Get your REST URL and token
git clone https://github.com/vishkx/nextjs16_realtime_chat.git
cd nextjs16_realtime_chatUsing Bun (recommended):
bun installOr using npm:
npm installCreate a .env.local file in the root directory:
# Upstash Redis Configuration
UPSTASH_REDIS_REST_URL=your_redis_rest_url
UPSTASH_REDIS_REST_TOKEN=your_redis_rest_token
# Optional: Custom API URL (for production)
NEXT_PUBLIC_API_URL=https://your-domain.comGet your Upstash credentials:
- Go to Upstash Console
- Create a new Redis database
- Copy the
UPSTASH_REDIS_REST_URLandUPSTASH_REDIS_REST_TOKEN
Using Bun:
bun run devOr using npm:
npm run devOpen http://localhost:3000 in your browser.
- Enter your username (auto-generated if not set)
- Set the maximum number of users (1-20)
- Click "CREATE SECURE ROOM"
- Share the room link with others
- Open the shared room link
- You'll automatically join if the room has available slots
- Start chatting in real-time!
- Self-Destruct Timer - Countdown shows remaining time (10 minutes)
- Copy Link - Easily share the room URL
- Destroy Now - Manually destroy the room and all messages
- Theme Toggle - Switch between light and dark modes
- Color Themes - Customize theme colors
nextjs16_realtime_chat/
βββ src/
β βββ app/ # Next.js App Router
β β βββ (app)/ # Main app routes
β β β βββ page.tsx # Home page (room creation)
β β β βββ layout.tsx # App layout
β β βββ room/
β β β βββ [roomId]/ # Dynamic room route
β β β βββ page.tsx # Chat room interface
β β βββ api/ # API routes
β β βββ [[...slugs]]/ # Elysia API handler
β β βββ realtime/ # Realtime WebSocket handler
β βββ components/
β β βββ custom/ # Custom components
β β β βββ theme-color-toggle.tsx
β β β βββ animated-theme-toggler.tsx
β β βββ ui/ # shadcn/ui components
β βββ lib/
β β βββ client.ts # Eden Treaty API client
β β βββ redis.ts # Upstash Redis client
β β βββ realtime.ts # Realtime server setup
β β βββ realtime-client.ts # Realtime client hooks
β βββ hooks/ # Custom React hooks
β βββ context/ # React context providers
βββ public/ # Static assets
βββ package.json
βββ tsconfig.json
βββ next.config.ts
# Start development server
bun run dev
# Build for production
bun run build
# Start production server
bun run start
# Run linter
bun run lint- Room Management: Rooms are stored in Redis with a 10-minute TTL
- Authentication: Token-based auth using HTTP-only cookies
- Real-time Updates: Upstash Realtime for instant message delivery
- Message History: Messages stored in Redis lists, synced with room TTL
- User Tracking: Connected users tracked per room with max capacity
- Push your code to GitHub
- Import project in Vercel
- Add environment variables:
UPSTASH_REDIS_REST_URLUPSTASH_REDIS_REST_TOKEN
- Deploy!
The app can be deployed to any platform supporting Next.js:
- Netlify
- Railway
- Render
- AWS Amplify
Make sure to set the environment variables in your deployment platform.
- Token-based Authentication - HTTP-only cookies for secure room access
- Room Capacity Limits - Prevents unauthorized access
- Automatic Expiration - Rooms and messages auto-delete after TTL
- No Persistent Storage - All data is temporary and ephemeral
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is open source and available under the MIT License.
- Upstash for Redis and Realtime services
- shadcn/ui for beautiful UI components
- Elysia.js for the fast API framework
- Next.js team for the amazing framework
For questions or suggestions, please open an issue on GitHub.
Made with β€οΈ using Next.js 16 and Upstash