A real-time chat app built with Firebase (Authentication + Firestore + Realtime Database + Hosting)
Demo: https://fir-chat-4ba55.web.app/
Frontend: SvelteKit + TypeScript + Tailwind CSS + Vite
Backend: Firebase Authentication, Firestore, Realtime Database, Cloud Functions
Deployment: Firebase Hosting
- Phone Authentication - Sign in with phone number and SMS verification
- User Onboarding - Set username and display name
- Real-time Messaging - Instant messaging with Firestore
- User Search - Find users by username to start conversations
- Presence Tracking - See when users are online/offline and last seen
- Message Chunking - Efficient handling of large chat histories
- Secure Backend - Cloud Functions handle server-side logic
- Node.js (v18 or later)
- Firebase CLI:
npm install -g firebase-tools - A Firebase project with Authentication, Firestore, and Realtime Database enabled
Connect to your Firebase project:
firebase login
firebase use --add-
Navigate to the web directory:
cd web -
Install dependencies:
npm install
-
Create a
.envfile in thewebfolder:PUBLIC_FIREBASE_CONFIG='{ "apiKey": "<YOUR_API_KEY>", "authDomain": "<YOUR_AUTH_DOMAIN>", "projectId": "<YOUR_PROJECT_ID>", "storageBucket": "<YOUR_STORAGE_BUCKET>", "messagingSenderId": "<YOUR_MESSAGING_SENDER_ID>", "appId": "<YOUR_APP_ID>", "measurementId": "<YOUR_MEASUREMENT_ID>" }' PUBLIC_RTDB_URL="<YOUR_REALTIME_DATABASE_URL>"
-
Start the development server:
npm run dev
-
Navigate to the functions directory:
cd functions -
Install dependencies:
npm install
-
Start the Firebase emulator:
npm run serve
├── web/ # SvelteKit frontend
│ ├── src/
│ │ ├── routes/ # App routes
│ │ ├── lib/ # Shared components and utilities
│ │ └── app.html # Main HTML template
│ └── static/ # Static assets
├── functions/ # Firebase Cloud Functions
│ └── src/
│ └── index.ts # Function definitions
├── firestore.rules # Firestore security rules
├── database.rules.json # Realtime Database rules
└── firebase.json # Firebase configuration
-
Build the web application:
cd web && npm run build
-
Deploy to Firebase by running below command at root directory:
firebase deploy
- SvelteKit: Full-stack web framework with file-based routing
- TypeScript: Type-safe JavaScript development
- Tailwind CSS: Utility-first CSS framework
- Firebase Auth: Phone number authentication with reCAPTCHA
- Firestore: NoSQL document database for messages and user data
- Realtime Database: Real-time presence tracking
- Cloud Functions: Serverless backend logic
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Commit your changes:
git commit -am 'Add some feature' - Push to the branch:
git push origin feature-name - Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- All sensitive operations are handled by Cloud Functions
- Firestore security rules prevent unauthorized access
- Phone authentication provides secure user verification
- Message chunking prevents database document size limits
