Explicitly add variables and values to .env file

I want to add some values to .env in my project during runtime. Is there any code to do this?

You can set them like you would any variable e.g. process.env.VAR='value'. Note though that it’s just temporary - the values are forgotten or reset to what’s in .env when your project restarts.

1 Like

Is there a way to store them permanently?

The file system is persistent, so either save the values to a local file or in a database. There are plenty of options with worked example code here: https://glitch.com/storage

1 Like