How To Create ENV Variables In React

preview_player
Показать описание
🌎 Find Me Here:

#Shorts
Рекомендации по теме
Комментарии
Автор

One of these shorts which you watch randomly and suddenly remember when you need them one day later😁😍

SamHartmannCom
Автор

In NextJS the prefix is NEXT_PUBLIC_. This way, they want to make clear that you are exposing this data to the client.

codinginflow
Автор

Environment variables are stored in the client side code so be VERY careful with which ones you use.

DO NOT store API KEYS, AWS KEYS and other sensitive data because using dev tools you can view all the env variables

lukecartwright
Автор

You the best. Literally was stuck on this for an hour and a half.

anthonyt
Автор

Thanks a lot for this video brother 👍🏻

rajdusane
Автор

When 1 minute shorts solves your problem which even 5 minutes video can't 😂

Vignesh-vi
Автор

what's an actual diff between meta and process? why did you use meta with vite and process with CRA

sulaimanshabbir
Автор

IMPORTANT: DO NOT STORE SECRETS IN ENVIRONMENT VARIABLES FOR ANY PUBLIC PROJECT!

While this is okay during development, environment variables in production should only be used for configuration data. No secret keys.

Why? Environment variables are global to your project and can be access by any package. It's not uncommon for log files to dump your entire env values. Nefarious packages might even scan for these deliberately.

Again, it's generally fine to use in development as long as you don't install suspicious packages. But in production, most hosting services will offer their own config variable system that is much more secure, so use that instead when the time comes.

An alternative to env variables during development is to create your own config file and import it only in files that need it. Just make sure to include the config file in your gitignore.

If you're working with a team, you can look into using secrets managers like Google's or Amazon's. But these cost money. If you're using Docker they have one included.

Ezoluna
Автор

Thank you so much brother, you saved me!

gregoryalvim
Автор

Great to know. Thanks Kyle as always! 👍

theisoj
Автор

OMG Thank you so much. Ur such a talented teacher. I thought .env could be used on backend apps only

MJstart
Автор

How to get the environment variable in production. I have set the environment variable using export in linux and I want to get that in react. How should approach the process?

towardsa.i.
Автор

Thank you! I hade mine in the src folder and it was driving me crazy trying to figure out why it wasn't working lol

Muhyideen
Автор

ERROR
import.meta may only appear in a module
???

Raezard
Автор

Is the prefix like REACT_APP or VITE is compulsary or is there any other work around for that?

propavangameryt
Автор

Are these variables runtime or build time? If I have a react application in a docker container can I simply change the value of a variable without rebuilding the image?If not, how can I achieve that?

vishalpagey
Автор

What's the point using env variables in front end?

xfqgfpt
Автор

Is it necessary to prefix with the REACT_APP_nameofvariable like in VITE_nameofvariable?

syedhaider
Автор

Why use .env in front? Where everything is published anyway?

the.yonlyyone
Автор

🎉 hey Idk that you have any tiktok channel? Your shorts are awesome

khambui