A private, self-destructing real-time chat application built with Next.js, Elysia, and Upstash. This project creates ephemeral, 1-on-1 chat rooms that automatically expire after a fixed duration or can be manually destroyed, ensuring strong privacy and security by design.
-
1-on-1 Secure Messaging Chat rooms are strictly limited to two participants, ensuring private and focused conversations.
-
Self-Destructing Rooms
- Auto-Expiry: Rooms and all associated messages automatically delete themselves after 10 minutes.
- Manual Destruction: Either participant can trigger an instant kill switch to immediately wipe the room and disconnect all users.
-
Real-Time Updates Instant message delivery and room state updates powered by Upstash Realtime.
-
Ephemeral Identity No sign-up or login required. User identities are generated per session and discarded once the room expires.
-
Full-Stack Type Safety End-to-end type safety using ElysiaJS with Eden Treaty, seamlessly connected to a Next.js App Router frontend.
- Runtime: Bun
- Frontend Framework: Next.js 16 (App Router)
- Backend API: ElysiaJS (served via Next.js Route Handlers)
- Database & Realtime: Upstash Redis
- Styling: Tailwind CSS v4
- State Management: TanStack Query
Before getting started, ensure the following are installed:
-
Bun (runtime & package manager)
curl -fsSL https://bun.sh/install | bash -
Upstash Account A Redis database from Upstash is required for message storage, TTL handling, and real-time updates.
-
Clone the repository
git clone https://github.com/yourusername/realtime-chat.git cd realtime-chat -
Install dependencies
bun install
-
Run the development server
bun dev
-
Open the application Visit:
http://localhost:3000
src/
├── app/
│ └── api/
│ └── [[...slugs]]/
│ └── route.ts
├── lib/
│ └── client.ts
└── proxy.ts
-
/src/app/api/[[...slugs]]/route.tsCore backend logic. Initializes the Elysia app that handles room creation, messaging, TTL enforcement, and destruction, all exposed through a Next.js Route Handler. -
/src/proxy.tsMiddleware proxy responsible for room access control. It ensures that no more than two users can join a room and assigns ephemeral session tokens. -
/src/lib/client.tsType-safe Eden client that creates a shared contract between the Elysia backend and the React frontend.
-
Message Retention Messages are stored in Redis with a strict TTL (Time To Live). Once the TTL expires or a room is manually destroyed, all data is permanently removed.
-
Room Capacity Enforcement The
proxy.tslogic checks the active connection count in Redis before allowing access, strictly enforcing a 2-user limit per room. -
No Persistent Identity No accounts, emails, or personal data are stored. Everything is session-based and ephemeral.
Contributions are welcome! Feel free to open issues or submit pull requests to improve features, performance, or documentation.
This project is open-source and available under the MIT License.