A web application for real-time emergency location tracking, part of the ClimateReady mobile app ecosystem. This web app allows emergency contacts to view the real-time location of users who have activated the SOS feature in the ClimateReady mobile app.
This web application serves as the companion to the ClimateReady mobile app's SOS feature. When a user activates an SOS alert from the mobile app, this web interface allows their emergency contacts to:
- Track their real-time location on a map
- See important medical information if shared by the user
- Receive updates on the emergency situation
- Access the information without needing to create an account
- Real-time Location Tracking: View live location updates of a person in distress
- No Login Required for Emergency Access: Emergency contacts can access the tracking map via a secure link
- Medical Information Display: Shows critical medical information if configured by the user
- Responsive Design: Works on desktop and mobile devices
- Secure Access: Uses secure tokens to ensure only authorized contacts can view the information
- Guided Emergency UI: Contextual overlays, status banners, and refreshed styling help responders understand session state at a glance
- Developer Diagnostics: Optional token debugger (enabled in development) assists with troubleshooting access links
/
– Login screen/login
– Explicit login route for administrators/access/:sessionId
– Authenticates and grants access to an SOS session/session/:sessionId
– Token validation hand-off for shared links/map/:sessionId
– Public emergency tracker view*
– Fallback not-found page
- React (with TypeScript)
- Firebase Authentication
- Firestore Database
- Google Maps API
- Vite build tool
- Node.js (v16 or higher)
- npm or yarn
- Firebase account
- Google Maps API key
-
Clone this repository:
git clone https://github.com/R-Tharanka/sos-live-tracker-map.git cd sos-live-tracker-map
-
Install dependencies:
npm install # or yarn install
-
(Optional) Generate a production build locally:
npm run build # or yarn build
-
Start the development server:
npm run dev # or yarn dev
-
Create a
.env
file based on.env.example
:cp .env.example .env
-
Configure your
.env
file with your Firebase and Google Maps API credentials:# Firebase Configuration VITE_FIREBASE_API_KEY=your-api-key VITE_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com VITE_FIREBASE_PROJECT_ID=your-project-id VITE_FIREBASE_STORAGE_BUCKET=your-storage-bucket VITE_FIREBASE_MESSAGING_SENDER_ID=your-sender-id VITE_FIREBASE_APP_ID=your-app-id # Google Maps API Key VITE_GOOGLE_MAPS_API_KEY=your-google-maps-api-key # App Configuration VITE_APP_URL=http://localhost:3000 VITE_APP_NAME=ClimateReady SOS Tracker
-
Launch the tracker in development (after configuring environment variables) using the command above.
-
Install Vercel CLI:
npm install -g vercel
-
Navigate to the project directory and deploy:
vercel
-
Follow the prompts to link your project and configure deployment settings.
-
A
vercel.json
configuration file is already included in the project to handle SPA routing. This ensures routes like/login
and/session/:id
work correctly. -
Set environment variables in the Vercel project dashboard:
- Add all the variables from your
.env
file - Update
VITE_APP_URL
to your deployed URL
- Add all the variables from your
-
Update the main ClimateReady app's environment variables:
- Set
SOS_WEB_APP_URL
to your deployed URL
- Set
If you encounter 404 errors when navigating directly to routes like /login
or /session/:id
:
-
Ensure the
vercel.json
file is in the root directory with the following content:{ "rewrites": [ { "source": "/(.*)", "destination": "/index.html" } ] }
-
Check that all image references in your components use imports rather than direct paths
// Do this: import logoImg from '/logo.png'; <img src={logoImg} alt="Logo" /> // Instead of this: <img src="/logo.png" alt="Logo" />
-
Verify the production build output (
npm run build
) is not checked into version control—the generatedbuild/
folder is now ignored by default. -
Make sure your environment variables are correctly set in the Vercel dashboard
This web app can also be deployed to:
- Firebase Hosting
- Netlify
- GitHub Pages (with some additional configuration)
This web application works in tandem with the ClimateReady mobile app. When a user activates the SOS feature in the mobile app, the following happens:
- The mobile app creates an SOS session in Firebase
- A secure token and session ID are generated
- A tracking link is created with the format:
https://your-deployed-url/session/{sessionId}?token={token}
- This link is sent to emergency contacts via SMS
- Emergency contacts can click the link to view the user's location in real-time
/src/components/
- React componentsLogin.tsx
- Authentication componentMapTracker.tsx
- Main map tracking componentSessionAccess.tsx
- Handles session token verification
/src/auth/
- Authentication logic/src/types/
- TypeScript type definitionsvercel.json
- Configuration for Vercel deployment with SPA routing support
- ClimateReady Mobile App
- The main mobile application that integrates with this web tracker
- Fork the repository
- Create a feature branch:
git checkout -b feature/new-feature
- Commit your changes:
git commit -m 'Add new feature'
- Push to the branch:
git push origin feature/new-feature
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.