Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

environment variable in nextjs

//process.env only work in server not in browser so it will show undefined 
//to fixed it use NEXT_PUBLIC_before APi key in .env.local or .env 
//this solution only work from version 9 of nextjs.
NEXT_PUBLIC_BACKEND_API="http://localhost:1337/graphql"
 
PREVIOUS NEXT
Tagged: #environment #variable #nextjs
ADD COMMENT
Topic
Name
4+9 =