Ask coding questions

← Back to all posts
Enhancement: .env vars for private API Keys
NguyenDa18 (3)

Hi I was wondering if it is possible to add .env variables to a REPL that will not be displayed to the public. Is it planned? Sometimes you just want to try a small example app but it requires a private key that should be stored in a private config or .env file. Thanks.

Comments
hotnewtop
ash15khng (712)

I don't understand the question, could you try explaining it again?

NguyenDa18 (3)

@ash15khng When you use a web API they often require a secret key for authentication and when you deploy or share your app the key should not be visible to the client, because they can check the frontend code. Basically, I was wondering if REPL.IT allows a user to share REPLs without exposing any secret configuration. Usually, the configuration is stored as environment variables and it would be great if REPL.IT allowed the option to add environment variables that can only be seen by you. https://www.npmjs.com/package/dotenv -More information about how environment variables work, using Node.js

ash15khng (712)

@NguyenDa18 Oh, you can use them by creating a file with the name .env, and the format is something like

USERNAME=random person
PASSWORD=securepassword

Note that there cannot be spaces beside the = or it would be part of the variable name.

NguyenDa18 (3)

@ash15khng I know how .env files work, I was just wondering how to use them in REPL.IT because if I created a .env file in a REPL I think it would be publicly visible.

ash15khng (712)

@NguyenDa18 Yea, it works, as long as you are signed in and you own the repl. If you share the repl, no one else can see your .env

NguyenDa18 (3)

@ash15khng That's great to hear! Thank you very much!