This is the documentation of version 1.0.0-rc.4. Go to the latest version, 1.0.0-rc.5.

Where your API key runs

Where the SDK runs decides how much care your API key needs:

TomTom's API key management best practices cover keys in general: scoping, segregation, rotation and monitoring. What follows is specific to the SDK, and to a key that has to sit in a page.

Which situation you are in

1. Node.js only, no front-end2. Browser plus your own backend3. Browser only4. Browser map behind a proxyScript, cron job or backend serviceapi.tomtom.comYour page (no key)Your Node.js APIapi.tomtom.comYour page (Map + Services)api.tomtom.comYour page (Map, no key)Your proxyapi.tomtom.com key from the environment your own resultskey from the environment every request carries the keytiles and services, session cookiekey from the environment
Where your code runs Who can see the key What to think about
Node.js script, job or backend service, no front-end Nobody outside your infrastructure Secret hygiene, and bounding what a job can spend
Node.js API behind a browser app Nobody, as long as you do not pass it on The same, plus keeping it out of what you return
Browser, Map bundle or Services bundle Anyone who opens the page The rest of this guide
React Native app, Services bundle Anyone who unpacks the app Same as the browser

Server-side apps (Node.js)

In a nightly geocoding job, a CLI script, your own API that calls routing, a queue worker, or tests and CI, the key stays inside your infrastructure. You don't need the proxying and hardening guides.

Read the key from the environment instead of your source code:

import { TomTomConfig } from '@tomtom-org/maps-sdk/core';

TomTomConfig.instance.put({
    apiKey: process.env.TOMTOM_API_KEY,
});

Two things are specific to the SDK:

On a server, the realistic failure is your own code, since every call is billed. Count a batch job's input before you start it, cap concurrency, and cache what you have already resolved.

If your Node.js code serves a front-end, keep the key out of everything you return to the browser, including config endpoints, server-rendered HTML and serialized state blobs.

Server-side rendering blurs the line. A framework that runs the same component on the server and the client will inline process.env.TOMTOM_API_KEY into the browser bundle. Variables with a public prefix (NEXT_PUBLIC_, VITE_) are client-visible by design. Check what your build actually ships before you assume a key is server-only.

Browser apps

A page that shows a map needs a key in the browser. For most applications that is fine.

Take a second look if your application is public and anonymous. Anyone who opens the page can read the key and use it from their own application, on your bill. Behind a login, you know who your users are. Self-service signup counts as public.

Ask yourself: if someone started using your key from their own application tomorrow, would you find out? If not, take these measures. They are settings on the key in the dashboard, not something you build:

The best practices detail each. Together they cap the damage and make a leak visible quickly, which is enough for many applications.

When a proxy is worth it

Only a server, your own or a proxy, takes the key off the page. The measures above leave the key public and limit what it is worth, which is often the right trade.

Two cheaper steps come first:

Move to a proxy when a stolen key would be a bill you would notice, when your application is public and anonymous at meaningful volume, or when you rotate keys because of abuse, not policy. An unguarded proxy is just your key with extra steps, so treat proxying your API calls and hardening your proxy as one job.

Next steps