Thanks Ado nice video. Let me add one thing.. I was getting undefined when I was doing this. I stopped and restart the server and then it was working perfectly. Thanks again!
About .env - the file for env variables in production, how is it suposed we access them for example when we deploy from Vercel if we dont push .env to the project's git repo?
when hosting the website in production eg netlify, would the hosting server be able to access the environmental variable? because we usually pass the variable to the servers as well. which are we going to pass? the one with NEXT_PUBLIC??
8:08 I think you are wrong. Any props that are passed through getServerSideProps end up in your front end source code. If you look at it and scroll all the way at the bottom you can see a script called __NEXT_DATA__ with all your props data. So your API keys are not private if you get them that way. Best to use them just through your API. Unless my understanding is wrong...
Hey Bryan. Yes and no. If you pass the data from the getServerSideProps() method as props into your react component then yes the data will be sent to the browser, but the contents of the function itself are never exposed and don’t get built as part of the browser bundle. So you can safely get the value from process.env and use it for example to make a call to a secured api, and pass that data as props to your component but not the value of the environment variable itself. Hope that helps.
Hey Ado, pretty neat stuff man, thanks. I"ve got a suggestion though, I think you should include a link to your other social media accounts so you're reachable, and I know the channel is pretty new, but man you're doing great, other things will follow gradually and eventually, safe bro! I definitely subscribed and smashed the bell too.. 😉🙏good luck!
Thanks Ado nice video. Let me add one thing.. I was getting undefined when I was doing this. I stopped and restart the server and then it was working perfectly. Thanks again!
Thanks a lot, this video should be added to the next JS documentation because it's not too clear how to use these environment variables!
what if i want to use an environment variable in a component that I don't want anybody to see?
awesome content! I just started on a Nextjs project and this was very useful!
thanks man as always proper and complete information !
does variables with NEXT_PUBLIC prefix when used in frontend... are exposed to the web?
Yes. If you use NEXT_PUBLIC it makes the variable available to the browser, so you shouldn't put any information that needs to be kept secret there.
@@ado how can i get the env variable in browser if i expose the env variable to the browser because i am not able to find it
Good content, wish to see more. Great work!
You saved me! thanks!
Thanks for the help!
@2:55 Not getting loaded env variable message in terminal. Do I have to change next.config.js?
It doesn't work for me and I dont know why. I am using Next 10
Thanks man! It helped me a lot❤
thanks man!! really helped me!
Dude this was very useful!❤️
Thanks. Very useful info :)
this is a very easy and good video. thank u
Awesome Broh! Thanks a lot
Thank you, this helped me a lot!
dude... sup super helpful
About .env - the file for env variables in production, how is it suposed we access them for example when we deploy from Vercel if we dont push .env to the project's git repo?
when hosting the website in production eg netlify, would the hosting server be able to access the environmental variable? because we usually pass the variable to the servers as well. which are we going to pass? the one with NEXT_PUBLIC??
Very good man! Thx a lot!
Thank you.
What about URLs? Would it work the same?
wow nice :)
thankyou so much!
Thanks, Aado!!
8:08 I think you are wrong. Any props that are passed through getServerSideProps end up in your front end source code. If you look at it and scroll all the way at the bottom you can see a script called __NEXT_DATA__ with all your props data. So your API keys are not private if you get them that way. Best to use them just through your API. Unless my understanding is wrong...
Hey Bryan. Yes and no. If you pass the data from the getServerSideProps() method as props into your react component then yes the data will be sent to the browser, but the contents of the function itself are never exposed and don’t get built as part of the browser bundle. So you can safely get the value from process.env and use it for example to make a call to a secured api, and pass that data as props to your component but not the value of the environment variable itself. Hope that helps.
@@ado oh that’s suuuper good to know! Thanks for those details!
so if i do not create .env.development does .env.local will work on production ?
Hi, can I set the apitoken in environtment variable from the login api response? thanks
Every time I do it, my env variables are always undefined.
Did you get any solution?
had the same issue, just stop the build and run it again.. solved my problem.
Hey Ado, pretty neat stuff man, thanks.
I"ve got a suggestion though, I think you should include a link to your other social media accounts so you're reachable, and I know the channel is pretty new, but man you're doing great, other things will follow gradually and eventually, safe bro!
I definitely subscribed and smashed the bell too.. 😉🙏good luck!
thx