A secure, private, self-destructing chat room application built with Next.js 16, Elysia, and Upstash. Messages are delivered in real-time and rooms automatically expire after a set duration.
- 🔒 Secure Room Creation: Generate unique, private chat rooms with nanoid.
- ⚡ Real-time Messaging: Instant message delivery powered by Upstash Realtime.
- ⏳ Self-Destructing Rooms: Rooms and all associated data automatically expire after 10 minutes (configurable).
- 💣 Manual Destruction: Instantly destroy a room and its history with a single click.
- 📜 Message History: Persistent history for the duration of the room's life.
- 🔗 Easy Sharing: Quick-copy room links to invite participants.
- Framework: Next.js 16 (App Router, React 19)
- API Engine: Elysia (running on Next.js API routes)
- Real-time: @upstash/realtime
- Database/Cache: Upstash Redis
- State Management: TanStack Query v5
- Validation: Zod
- Styling: Tailwind CSS 4
- An Upstash account (Redis and Realtime).
Create a .env.local file in the root directory:
UPSTASH_REDIS_REST_URL=your_redis_rest_url
UPSTASH_REDIS_REST_TOKEN=your_redis_token
UPSTASH_REALTIME_TOKEN=your_realtime_tokennpm installnpm run devOpen http://localhost:3000 with your browser to see the result.
| Endpoint | Method | Description |
|---|---|---|
/api/room/create |
POST |
Create a new chat room |
/api/room/ttl |
GET |
Get room time-to-live |
/api/room |
DELETE |
Destroy a room |
/api/messages |
POST |
Send a message |
/api/messages |
GET |
Get all messages in a room |
src/
├── app/
│ ├── api/[[...slugs]]/ # Elysia API routes implementation
│ ├── room/[roomId]/ # Dynamic chat room route
│ └── page.tsx # Application landing page
├── components/ # Shared UI components
├── hooks/ # Custom React hooks (use-username, etc.)
├── lib/ # Client initializations (Redis, Realtime)
└── types/ # TypeScript definitions
This project was built following the tutorial: Build a Complete Real-Time Chat with Next.js 16, Redis, Tailwind (2025).
This project is licensed under the MIT License.