Skip to content

Add support for reading environment variables from .env files #13647

@ANGELUSD11

Description

@ANGELUSD11

Describe the project you are working on

My game is a simple 2d space shooter, but to implement a communication bridge with external services, I rely on a parser to avoid exposing my tokens and sensitive data. For example, I have several implementations with the Discord API to use bots or user state.

Describe the problem or limitation you are having in your project

Not having native support for .env environment variable files .env

Describe the feature / enhancement and how it helps to overcome the problem or limitation

I understand that exposing keys or tokens directly inside a project can be a security risk, but having native support for loading environment variables from a .env file would provide a clean and standardized way to configure external services or APIs. This would avoid the need for custom parsers, reduce duplicated solutions across projects, and offer a more reliable workflow for developers who integrate external backends or cloud services.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Add a built-in API to load .env files at runtime or at project startup.
Provide a simple method in GDScript/C#/C++ such as:

var config = Env.load(".env")
var api_key = config.get("API_KEY")

This would allow developers to retrieve environment variables in a consistent and engine-supported way without needing custom parsers or third-party add-ons.

If this enhancement will not be used often, can it be worked around with a few lines of script?

Even if the code is short, it still needs to be maintained, tested across platforms, and kept compatible with future engine releases. Having an official implementation avoids the long-term maintenance burden for users.

Is there a reason why this should be core and not an add-on in the asset library?

Right now, every developer who needs .env support must either write their own parser, copy code from other projects, or install third-party add-ons of varying quality. Native support ensures consistency, reliability, and long-term maintenance.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions