Back to examples

Node/Express Backend

This backend example keeps the PlaceField secret key on the server and exposes a local /api/locations/autocomplete route for your app.

Run Locally

cd examples/node-express
npm install
npm run dev

Open http://localhost:3000/.

Configure The Key

Replace the placeholder in placefield.config.json when you want real PlaceField results:

{
  "placeField": {
    "secretKey": "pf_live_xxx",
    "autocompleteUrl": "https://api.placefield.dev/v1/locations/autocomplete"
  },
  "server": {
    "port": 3000
  }
}

What The Server Does

This static guide does not call the PlaceField API. Clone the repo and run the server locally to test with your key.

View source on GitHub