A modern Next.js application showcasing interactive maps using React Leaflet with modern UI components.
This project demonstrates how to integrate React Leaflet into a Next.js application to create interactive, feature-rich maps with modern UI components.
- Next.js 15.4.6 - React framework with App Router
- React 19.1.0 - Latest React with concurrent features
- TypeScript - Type-safe JavaScript development
- React Leaflet 5.0.0 - React components for Leaflet maps
- Leaflet 1.9.4 - Open-source JavaScript library for interactive maps
- Leaflet Default Icon Compatibility 0.1.2 - Fixes icon compatibility issues
- Tailwind CSS 4 - Utility-first CSS framework
- PostCSS - CSS processing
- ESLint - Code linting and quality
- TypeScript - Static type checking
- Git - Version control
-
Clone the repository
git clone https://github.com/mohd-khan09/React-leaflet.git cd React-leaflet
-
Install dependencies
npm install
-
Start the development server
npm run dev
-
Open your browser Navigate to http://localhost:3000
npm run dev
- Start development server with Turbopacknpm run build
- Build the application for productionnpm run start
- Start the production servernpm run lint
- Run ESLint for code quality
react-leaflet/
├── src/
│ └── app/
│ ├── components/ # React components
│ ├── globals.css # Global styles
│ ├── layout.tsx # Root layout
│ └── page.tsx # Home page
├── public/ # Static assets
├── package.json # Dependencies and scripts
├── tsconfig.json # TypeScript configuration
├── tailwind.config.js # Tailwind CSS configuration
└── README.md # This file
- Interactive Maps - Full-featured Leaflet maps with React components
- Modern UI - Clean, responsive design with Tailwind CSS
- TypeScript - Type-safe development experience
- Performance - Optimized with Next.js and Turbopack
The project includes proper Leaflet configuration with:
- Default icon compatibility fixes
- TypeScript support
- App Router enabled
- TypeScript support
- Tailwind CSS integration
- ESLint configuration
Provides React components that wrap Leaflet functionality, making it easy to create interactive maps in React applications.
Fixes common issues with Leaflet icons in modern bundlers and frameworks.
To create a basic map component:
import { MapContainer, TileLayer, Marker, Popup } from "react-leaflet";
import "leaflet/dist/leaflet.css";
function MyMap() {
return (
<MapContainer
center={[51.505, -0.09]}
zoom={13}
style={{ height: "400px" }}
>
<TileLayer
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
/>
<Marker position={[51.505, -0.09]}>
<Popup>
A pretty CSS3 popup. <br /> Easily customizable.
</Popup>
</Marker>
</MapContainer>
);
}
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is open source and available under the MIT License.
If you have any questions or need help, please open an issue on GitHub or contact the maintainer.
Happy Mapping! 🗺️