> For the complete documentation index, see [llms.txt](https://plutolabs.gitbook.io/plutoframework/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://plutolabs.gitbook.io/plutoframework/make-your-application/environment-variables.md).

# Environment variables

{% hint style="success" %}
Up to date
{% endhint %}

To set environment variables go to `PlutoFramework/appsettings.json` file (if the file does not exist, create it) and fill in the contents like this:

```json
{
    "VARIABLE_NAME_1": "value 1",
    "VARIABLE_NAME_2": "value 2"
}
```

These environment variables then need to be loaded in `PlutoFramework/MauiProgram.cs` using the `AddAppSettings` method. Add it to your code:

```csharp
public static MauiAppBuilder AddAppSettings(this MauiAppBuilder builder)
{
#pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type.
    using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream($"{nameof(YourAppNamespace)}.appsettings.json");
#pragma warning restore CS8600 // Converting null literal or possible null value to non-nullable type.

    if (stream is null)
    {
        return builder;
    }

    IConfigurationRoot configuration = new ConfigurationBuilder()
        .AddJsonStream(stream)
        .Build();

    builder.Configuration.AddConfiguration(configuration);

    return builder;
}
```

```csharp
var builder = MauiApp.CreateBuilder();
builder
    .UseMauiApp<App>()
    .UseMauiCommunityToolkit()
    .UsePlutoFramework()
    .AddAppSettings(); // Add this line

var app = builder.Build();
```

You can then access the environment variable like this:

```csharp
var configuration = MauiProgram.Services.GetService<IConfiguration>();

var value1 = configuration.GetValue<string>("VARIABLE_NAME_1");
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://plutolabs.gitbook.io/plutoframework/make-your-application/environment-variables.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
