✨
Help-a-Family Manual
  • Help a Family Docs
  • Info for Charities
  • Info for API Users
  • Tutorial
  • Contentful
  • Environment Variables
    • Lighthouse CI
  • Troubleshooting
  • Contributing to Help-a-Family
    • Fork and Clone the Repo
    • MHF Javascript/React Style Guide
    • MHF CSS Guide
    • Contributor Power Tips
Powered by GitBook
On this page
  • How This Project Sets Per-Environment Variables
  • Google Maps API Key
  • Getting a Key
  • Key Restrictions
  • Setting Your Key for Local Development

Was this helpful?

Environment Variables

PreviousContentfulNextLighthouse CI

Last updated 3 years ago

Was this helpful?

We use environment variables to store secrets such as API keys.

How This Project Sets Per-Environment Variables

To set environment variables in each environment:

  • Dev: Copy .env.example to .env then replace any sample values with real ones as per below

  • Prod: Set the Preview and Production values in

Google Maps API Key

NEXT_PUBLIC_GMAPS_JS_API_KEY

API key for the Maps JavaScript API.

Getting a Key

Instructions for getting this key:

In the Google console, name it something like NEXT_PUBLIC_GMAPS_JS_API_KEY (Dev, audreyfeldroy) or NEXT_PUBLIC_GMAPS_JS_API_KEY (Prod):

That will help you identify which key is for which environment.

Key Restrictions

If you're just using this key for local development, it's okay to leave Key restrictions as None like this:

A production key should have these restrictions:

Setting Your Key for Local Development

When you run yarn dev, if your Google Maps JS API Key isn't set yet you'll get an error in the browser JS console like:

To fix that:

  1. Set this in .env, replacing it with your actual key:

NEXT_PUBLIC_GMAPS_JS_API_KEY = ""

  1. ???

For the Vercel preview key, the Website restrictions setting will be something like:

js?v=3.exp&libraries=geometry,drawing,places&key=undefined:100 Google Maps JavaScript API error: InvalidKeyMapError

https://developers.google.com/maps/documentation/javascript/error-messages#invalid-key-map-error
Vercel > Settings > Environment Variables
Maps JavaScript API: Using API Keys > Creating API Keys
Google Maps JS API Key Naming
Google Maps JS API Key Restrictions: Prod Environment
Google Maps JS API Key Restrictions: Dev Environment