A React-based travel tracking application built with Vite, React Router, and Leaflet maps.
- Node.js 16+ and npm
- Backend API running on
http://localhost:9000(or configure withVITE_API_URL)
# Install dependencies
npm install
# Create .env.local for local development
cp .env.example .env.local
# Start the development server
npm run dev
# In a separate terminal, start the JSON server (for local backend)
npm run serverThe app will be available at http://localhost:5173
# Build the optimized production bundle
npm run build
# Preview the production build locally
npm run preview# Install Netlify CLI globally
npm install -g netlify-cli
# Login to Netlify
netlify login
# Deploy from project root
netlify deploy --prod-
Push code to GitHub
git init git add . git commit -m "Initial commit" git branch -M main git remote add origin <your-github-repo-url> git push -u origin main
-
Connect to Netlify
- Go to Netlify
- Click "New site from Git"
- Select your GitHub repository
- Netlify will auto-detect the build settings from
netlify.toml
The netlify.toml file contains the deployment configuration:
- Build command:
npm run build - Publish directory:
dist - Routing: Configured for SPA (Single Page Application)
For production on Netlify, you need to set the API endpoint:
- In Netlify dashboard, go to Site settings → Build & deploy → Environment
- Add an environment variable:
- Key:
VITE_API_URL - Value: Your production API URL (e.g.,
https://api.example.com)
- Key:
Or edit the netlify.toml file directly and update the VITE_API_URL in the production context.
src/
├── components/ # React components
├── contexts/ # React context (CitiesContext, FakeAuthContext)
├── hooks/ # Custom hooks (useGeolocation, useUrlPosition)
├── pages/ # Page components
├── App.jsx # Main app component
├── main.jsx # React entry point
└── index.css # Global styles
✈️ Track cities and countries you've visited- 🗺️ Interactive map powered by Leaflet
- 📍 Add new cities with geolocation
- 🔐 Protected routes with fake authentication
- 📱 Responsive design
- ⚡ Code splitting and lazy loading
- React 18.2.0
- Vite 4.2.0
- React Router 6.9.0
- Leaflet 1.9.3
- React Leaflet 4.2.1
- React DatePicker 4.11.0
- The app uses a JSON Server mock backend by default for local development
- For production, you'll need to connect a real API backend
- Update the
VITE_API_URLenvironment variable for your API endpoint - Ensure CORS is properly configured on your backend API
"API not found" error on Netlify
- Verify
VITE_API_URLis set correctly in Netlify environment variables - Ensure your API backend is running and accessible from Netlify
Blank page after deployment
- The
netlify.tomlfile handles SPA routing - all requests go toindex.html - Check browser console for errors
Cities not loading
- Verify the API endpoint is correct
- Check CORS headers on your backend API
- Ensure the backend is running and accessible