npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

leaflet-osm-proxy-next

v1.0.3

Published

GDPR-compliant OpenStreetMap tile proxy for Next.js App Router

Downloads

333

Readme

Leaflet OSM Proxy Next

A GDPR-compliant, filesystem-caching OpenStreetMap proxy for Next.js App Router.

Why use this?

Using standard OpenStreetMap (OSM) tile servers (tile.openstreetmap.org) in your application exposes your users' IP addresses to third-party servers immediately upon loading the map. Under GDPR (DSGVO), this usually requires a Cookie Banner or a "Click-to-Load" consent overlay.

This package solves that problem:

  1. Proxy: It routes all tile requests through your Next.js server.
  2. Privacy: OSM only sees your server's IP, not your users'. No consent banner needed!
  3. Cache: It saves tiles to your local disk. Subsequent requests are instant and don't hit OSM servers (respecting their usage policy).

Installation

# Using npm
npm install leaflet-osm-proxy-next
  1. Create the API Route (Server-Side) Create a dynamic route handler in your Next.js App Router to handle the proxying.

    File: app/api/tiles/[z]/[x]/[y]/route.ts

import { createTileProxyHandler } from "leaflet-osm-proxy-next";
export const GET = createTileProxyHandler({
  userAgent: "LeafletOSMProxy/1.0", // Customize your User-Agent
  cacheFolder: "tile-cache",        // Folder to store cached tiles
});
  1. Configure the Map (Client-Side) Point your Leaflet TileLayer to your new API route instead of the official OSM server.

    File: components/Map.tsx

"use client";
import { MapContainer, TileLayer } from "react-leaflet";
import "leaflet/dist/leaflet.css";

export default function MyMap() {
  return (
    <MapContainer center={[52.52, 13.4]} zoom={13} scrollWheelZoom={false}>
      <TileLayer url="/api/tiles/{z}/{x}/{y}" />
    </MapContainer>
  );
}
  1. Update .gitignore Since this package saves images to your disk, you should ignore the cache folder so you don't commit thousands of PNG files to Git.

    File: .gitignore

# ... other ignores
tile-cache/

⚠️ Deployment Notice

This package relies on the Local Filesystem (fs) to cache images.

✅ Works perfectly on:

  • VPS / Virtual Machines (DigitalOcean, Hetzner, EC2)

  • Docker Containers (Coolify, Railway with Volumes, Portainer)

  • Self-Hosted Next.js

❌ Does NOT work well on:

  • Serverless Environments (Vercel, Netlify, AWS Lambda)

📝 License

MIT License

Made by TobeyTG ✌️