Learn to Code via Tutorials on Repl.it!

← Back to all posts
Hiding your secret tokens with Replit Secrets
InvisibleOne (2933)

Ok, so for the last few days I've seen quite a lot of questions in the ask space about hiding Discord Bot Tokens or other secrets now that the replit env's are gone.
A lot of people are panicking because their bots aren't working and they are afraid that they aren't going to be able to keep their token secret, but replit has already given out the answer, with the new secrets system. It's simple, easy to use, and frankly more intuitive then the old .env files, I think it's awesome.
Now, if you want you can read the docs for replit secrets, right here: https://docs.replit.com/repls/secrets-environment-variables

Or you can take look at this step be step guide to using secrets.

First things first you need to open up the Secret's Manager (Is that it's real name???)

Then you need to create a secret, giving it a name and a value.

Secret's are so easy that replit automatically generates you the code to get the value of your secret, just press insert and it will put it into your code.

Make sure to IMPORT OS

import os #don't forget to import me!

or else you won't be able to read environment variables.

And just like that, secrets is working, keeping your token or secret message visible only to you.

EpicGamer007 (1765)

In java it is

In nodejs, it is

codingjlu (170)

@EpicGamer007 it's easier to just use process.env.ENV_KEY in node IMO.

EpicGamer007 (1765)

@codingjlu yes that works too.its a javascript object so either way works