Category: How do I do X?
Updated

This solution is summarized from an archived support forum post. This information may have changed. If you notice an error, please let us know in Discord.

Access environment variables

Issue

I want to access environment variables that I define in the values.yml file from the AppSmith application, but it's currently not possible as envs are not accessible in Javascript apps today. I need this to differentiate between multiple environments (dev, prod) and apply specific restrictions based on the current environment. These features are currently on the AppSmith roadmap, and I've added my use case on GitHub to help prioritize them.

Resolution

The solution to accessing environment variables defined in the values.yml file from AppSmith application is currently not possible as envs are not accessible in Javascript apps. However, AppSmith has two feature requests on their roadmap: Multiple Environments and Read environment variables for datasource values.

One recommended alternative to accessing environment variables is to use process.argv in the Node.js runtime environment to access command line arguments and parse them as variables. Another option is to use a third-party library like dotenv to load environment variables from a .env file.

AppSmith recommends adding comments with use cases on GitHub to help prioritize the feature requests on their roadmap.