Environment variables let you pass configuration values — like a Discord bot token or an API key — to your application without hardcoding them in your source code. On Daki Hosting, the recommended approach is to create aDocumentation Index
Fetch the complete documentation index at: https://wiki.daki.cc/llms.txt
Use this file to discover all available pages before exploring further.
.env file directly on your server using the Portal’s file manager or SFTP.
What you’ll learn
- What environment variables are and why they matter
- How to create a
.envfile on your server - How to load
.envvalues in Node.js and Python - Best practices for keeping secrets safe
What Are Environment Variables?
Environment variables are key-value pairs that your running application can read from its environment. They are the standard way to:- Store sensitive values (tokens, API keys, passwords) separately from code
- Change configuration without modifying or redeploying source files
- Avoid committing secrets to version control
Creating a .env File
The simplest and most reliable way to manage environment variables on Daki is to create a .env file on your server. You can do this in two ways:
Option 1: Using the File Manager (quick edits)
- Open your server in the Portal (portal.daki.cc).
- Go to the Files tab.
- Click New File and name it
.env. - Click the file to open it in the web editor and add your variables:
- Click Save.
- Restart your server.
Option 2: Using SFTP (recommended for initial setup)
Connect to your server via SFTP (credentials in the Settings tab) and upload your.env file directly from your local machine. See File Manager for SFTP setup instructions.
Loading .env Values in Your Application
Applications do not automatically read .env files — you need a library to load them into the environment.
Node.js — using dotenv
Install the package (add it to your package.json as a dependency):
Python — using python-dotenv
Add python-dotenv to your requirements.txt:
.env File Format
Each line in a .env file follows the format KEY=VALUE:
- Keys are typically uppercase with underscores.
- Values do not need quotes, but quotes are supported.
- Lines starting with
#are comments and are ignored.
Best Practices
- Never hardcode tokens or secrets in your source code files, especially if your code is on GitHub.
- Add
.envto your.gitignoreso it is never accidentally committed. - Create your
.envfile on the server, not locally — or use SFTP to upload a local.envthat is excluded from version control. - Restart your server after creating or modifying your
.envfile. - Use descriptive key names that make your configuration self-documenting.
Next Steps
- Startup Settings — Configure your install command, startup command, and Docker image.
- Deploy a Discord.js Bot — Full deployment walkthrough including token setup.
- Deploy a Python Bot — Full deployment walkthrough including token setup.