Is there a way to create an .env file if I really need to?

I have a code snippet that manually reads the .env file and I want to use Replit to demonstrate it. It’s a private Replit so I don’t worry about leaking secrets. Plus, there are no secrets involved, just plain key=value pairs.

There are many topics explaining that secrets are now managed via a UI panel instead of .env – fair enough but is there a way to create an .env file if I know what I’m doing?

(Currently, I name a file differently, like .env2, but that’s slightly confusing for the readers of my Replit.)

Replit doesn’t support .env files. Instead, they have secrets.
Go to Tools → Secrets and create a secret.

Here’s a Python example of how to use secrets:

import os

value = os.environ['key']

print(value)

Also I just realized you already knew about secrets. AFAIK, there is no way to create .env files.

Yeah exactly I know about secrets but my specific code example manually reads an .env file and doesn’t use something like process.env.XYZ or similar.

I’ll stick with my .env2 workaround then but it’s a bit strange.

2 Likes

yes I’ve always argued this since they are protecting those who don’t want to be protecting and instead limiting experienced devs…