Home
Softono
freemap-v3-react

freemap-v3-react

Open source Apache-2.0 TypeScript
45
Stars
18
Forks
99
Issues
8
Watchers
1 week
Last Commit

About freemap-v3-react

Freemap Slovakia web application (www.freemap.sk)

Platforms

Web Self-hosted

Languages

TypeScript

Freemap Slovakia Web Application

Source of www.freemap.sk, the web map portal maintained by OZ Freemap Slovakia.

Freemap is a free, non-commercial web map application built on OpenStreetMap data. Its focus is a detailed outdoor map for hiking, cycling, cross-country skiing and horse riding across Europe, complemented by many additional base and overlay layers and by tools for search, route planning, drawing and measurement, GPX viewing, live tracking, personal maps, map embedding, and export.

This repository is the frontend — a React single-page application. It talks to:

  • the Freemap API server (freemap-v3-api) for accounts, photos, tracking, saved maps and purchases, and
  • external tile, routing (GraphHopper) and geocoding (Nominatim / Overpass) services.

Tech stack

  • React 19 + Redux Toolkit (application state is reflected in the URL hash)
  • Leaflet / react-leaflet with MapLibre GL for vector layers
  • TypeScript, type-checked with tsgo
  • rspack bundler, Biome for linting/formatting, pnpm as the package manager
  • Zod schemas for validation (see CLAUDE.md for conventions)

Requirements

  • Node.js 22+
  • pnpm
  • A running Freemap API server for features that depend on the backend (login, photos, tracking, saved maps, export); the map itself renders without it.

Compiling and running in development mode

  1. Map local.freemap.sk to 127.0.0.1 in your system hosts file (on Linux and macOS this is /etc/hosts):

    127.0.0.1 local.freemap.sk
  2. Install dependencies:

    pnpm install
  3. Start the dev server (it compiles protobufs, syncs language files, and rebuilds on change):

    pnpm start
  4. Trust the development CA certificate in your browser (the dev server is served over HTTPS).

  5. Open the application at https://local.freemap.sk:9000/.

Building for production

The build target is selected with the DEPLOYMENT environment variable:

  • unset or dev — development build for local.freemap.sk (uses local backend / base URLs).
  • www — production build for www.freemap.sk (wires up the production backend, GraphHopper, Matomo, Sentry and Facebook app IDs).
  • any other value (e.g. next) — a production-optimized build that still uses the local / default URLs.
pnpm install
DEPLOYMENT=www pnpm build

The static web resources are emitted into the dist/ directory.

Deploying www.freemap.sk is done with the dep script, which runs a www production build, injects and uploads Sentry source maps, and rsyncs dist/ to the server:

pnpm dep

Server (nginx) configuration

The production nginx site configs are checked into this repo under etc/nginx/sites-available/ as a reference for what is actually deployed:

Both serve the static build from /home/freemap/www and share the same cache-header policy, which is critical to get right — mismatched headers pin users to stale hashed asset names and break the layout after a deploy:

  • Entry HTML (index*.html, the / redirect), service workers (sw.js, upload-sw.js) and assets-manifest.json are served Cache-Control: no-store, max-age=0 — they are unhashed and must never go stale.
  • Content-addressed assets (rspack emits 16-char [contenthash]/[chunkhash] names) are max-age=31536000, immutable.
  • *.png / *.jpg get a one-year max-age (without immutable).

The configs also handle: HSTS / Referrer-Policy headers, HTTP→HTTPS redirect and HTTP/3 (QUIC) via Certbot-managed TLS, per-user directory listings under /~<user>/, search-engine sitemap rewrites for bots on /, /mbtiles offline-map downloads, and a reverse proxy for /tiles/parametric-shading.

When changing build-output naming, the service worker, or the asset manifest, update these configs in the same change set.

Environment variables

Most deployment-specific values are derived from DEPLOYMENT (see above). The remaining overrides:

  • FM_MAPSERVER_URL — base URL of the Mapnik tile server, without a trailing slash (default https://outdoor.tiles.freemap.sk; e.g. http://localhost:4000 for local rendering).
  • PREVENT_ADS — if set (to any value), disables the ad banner.

Documentation

Deeper reference docs live in doc/:

src/static/llms.txt is a hand-maintained, user-facing description of the application (its functions, modals and map layers) for AI assistants, served at www.freemap.sk/llms.txt per the llmstxt.org convention. Keep it in sync when changing user-visible behavior — see CLAUDE.md.

Contributor notes for Claude Code (workflow, conventions): CLAUDE.md.

Translation (i18n)

The English master is src/translations/en.tsx; other locales are edited via their *.template.tsx files (the plain *.tsx files are generated — see CLAUDE.md).

Files holding translatable text:

License

Apache-2.0