score:5

this is how i got my setup to work...

  1. i have an env.local file for local dev key. add .env.local.* to .gitignore this file has my key/value pair like so:

1 next_public_g_key=aflkefjlkwblahblahblah

  1. i have a next.config.js file that has this key as well in an env space:

env: { next_public_g_key: process.env.next_public_g_key } (process.env works out of the box according to the docs)

  1. i deploy to vercel so i create a secret with the actual value of the key...:

$> yarn now secret add myappname_prod_g_key aflkefjlkwblahblahblah

  1. i go to my app in vercel > settings > environment variables and create a new one in the ui, mapped to the secret i just made in the command line.

vercel environment variable mapped to secret


Related Query

More Query from same tag