Real-time chat application built with Next.js and Ably Chat SDK.
- Real-time messaging with message history
- Typing indicators and online presence
- Message editing
- Message grouping (iMessage/Discord-style)
- Room-based chat with shareable room IDs
- Token-based authentication
- 24-hour message retention
- Responsive design with mobile support
- Input validation and XSS protection
- Error boundaries for graceful error handling
- Next.js 15 - React framework with App Router
- React 19 - UI library
- Ably Chat SDK - Real-time messaging infrastructure
- TypeScript - Type safety
- Tailwind CSS - Styling
- Zod - Schema validation
- Biome - Linting and formatting
src/
├── app/ # Next.js app router
│ ├── api/ # API routes (token auth)
│ ├── room/[id]/ # Dynamic room pages
│ └── page.tsx # Home page
├── components/
│ ├── chat/ # Chat-related components
│ │ ├── avatar.tsx
│ │ ├── chat-box.tsx
│ │ ├── message-list.tsx
│ │ └── ...
│ ├── error-boundary.tsx
│ └── loading-spinner.tsx
└── lib/ # Utilities and config
├── config.ts # Environment config
├── constants.ts # App constants
├── validation.ts # Input validation
├── error-handler.ts # Error handling
└── types.ts # Shared types
- Install dependencies:
npm install
# or
pnpm install- Configure environment variables:
Copy .env.example to .env.local and add your Ably API key:
cp .env.example .env.localGet your API key from ably.com/signup.
- Run the development server:
npm run dev
# or
pnpm devOpen http://localhost:3000 in your browser.
npm run dev- Start development servernpm run build- Build for productionnpm run start- Start production servernpm run lint- Run Biome linternpm run format- Format code with Biome