Next.js: Best practice for API Route environment variables

Created on 21 Jul 2019  路  4Comments  路  Source: vercel/next.js

Question about Next.js

I am currently in the process for updating my app to 9. I love the initiative behind api routes.
One thing that isn't clear here is the best way to load environment variables in to the app.

Is there anything specific about Next.js I should bare in mind when setting them?

I previously had the variables loaded in to an .env file

Most helpful comment

@powderham did you ask this question elsewhere? would be helpful if you shared a link

All 4 comments

Please use StackOverflow or https://spectrum.chat/next-js for questions. GitHub issues are for reporting bugs and requesting features. The issue template you鈥檝e edited states this.

Will do

I stumbled on this issue before noticing there is an example for loading from a .env file: https://github.com/zeit/next.js/tree/master/examples/with-dotenv

@powderham did you ask this question elsewhere? would be helpful if you shared a link

Was this page helpful?
0 / 5 - 0 ratings