- Sign in at replit.com and open your project from the dashboard.
- In your workspace, click New Tab and search for Secrets in the left sidebar (the lock icon).
- In the Key field, enter a name for your variable - for example, [Name]_TOKEN.
- In the Value field, paste your secret value - for example, your Telegram or Discord bot token.
- Click Add/Update new secret to save. Your variable is now available to your project as an environment variable.
How to Set Environment Variables in Replit
Try this interactive demo to learn how to set environment variables in Replit.
📌 Why this matters
Why this matters
Hardcoding sensitive values like API keys and tokens directly in your code is a serious security risk - anyone who views your project can see them. Storing them in Replit's Secrets tab keeps them encrypted and hidden while still making them accessible to your app at runtime. This is especially important for bot projects where your token grants full control over your bot's account. It's a simple step that protects your project from unauthorized access and follows industry-standard security practices.
Your product deserves an interactive demo
Similar Articles
No items found.
This website uses cookies to ensure you get the best experience on our website. Learn More
Got it
.gif)
