This is the documentation of version 0.64.0. 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)

A nightly geocoding job, a CLI script, an API of your own that calls routing, a queue worker, tests and CI: the key stays inside your infrastructure, so the proxying and hardening guides are not for you.

Read the key from the environment rather than from source:

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

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

Particular 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, what you return to the browser must not contain the key: not in a config endpoint, not in server-rendered HTML, not in a serialized state blob.

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, and variables with a public prefix (NEXT_PUBLIC_, VITE_) are client-visible by design. Check what your build actually ships before assuming 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.

It deserves a second look when 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.

The test: 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, nothing you have to build:

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

When a proxy is worth it

Only a server, yours or a proxy, takes the key off the page. Everything above leaves the key public and limits 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 rather than policy. An unguarded proxy is your key with extra steps, so proxying your API calls and hardening your proxy are one job.

Next steps