DEV Community

SETTING UP ENVIRONMENT VARIABLES IN REACT-VITE PROJECTS

Afikode Olusola Emma on February 28, 2023

INTRODUCTION It is no news that pushing some certain sensitive part of your code to a remote repository is not advisable for security reasons. Expo...
Collapse
 
johnywhyte profile image
johnywhyte

An interesting, but theres a package called dotenv. I am guessing they serve the same purpose. why use vite over dotenv. I have on used dotenv on Node.js projects though. is VITE the best environment variable package for react apps? and why?

Collapse
 
junojulius profile image
Juno Burger

Vite is a build tool, akin to webpack.
It takes away quite a bit of setting up and boilerplate that you'd get with webpack and its dependencies, and is relatively fast (especially in combination with SWC).

It also has built-in support for environment variables.
dotenv is useful for a standalone package, since nodejs doesn't support handling environment variables out-of-the-box.