Comment on page
Backend Environment Variables
This page describes how to set environment variables for your backend classes.
These variables can be either secrets such as database keys or 3rd party API keys, or variables to use globally across your backend classes.
On the
Backend
tab, click on the Environment Variables
button:
Add the environment variables like a
<key, value>
pair. After adding all the environment variables hit the Save
button:
Note: You can also import environment variables from a file using
Import from .env
button.You can load your environment variables when deploying
genezio
in the CLI by appending the following flag:genezio deploy --env .env
The environment variables used on the deployed environment are exported.
TypeScript
Dart
To access an environment variable use
process.env.MY_VARIABLE
main.ts
1
const myVariable = process.env.MY_VARIABLE;
2
console.log('Print environment variable', myVariable);
To access an environment variable use
Platform.environment['MY_VARIABLE']
main.dart
1
import 'dart:io';
2
3
void main() {
4
my_variable = Platform.environment['MY_VARIABLE'];
5
print(my_variable);
6
}
Note: There is no need to import specific libraries for loading environment variables (such as
dotenv
), genezio
loads them for you.
Last modified 2mo ago