private static async void InitializeSupabaseAsync()
{
var url = Environment.GetEnvironmentVariable("SUPABASE_URL");
var key = Environment.GetEnvironmentVariable("SUPABASE_KEY");
SupabaseClient = new Client(url, key, new Supabase.SupabaseOptions
{
AutoConnectRealtime = true
});
await SupabaseClient.InitializeAsync();
}Loading

Sandhiya PriyaPosted Oct 6, 2025, 4:34 AM
Let’s go step-by-step to add and use Environment Variables in Visual Studio for your C# project
Step 1: Open Project Properties
In Visual Studio, right-click on your project name in Solution Explorer.
Select Properties.
Go to the Debug tab (on the left).
Step 2: Add Environment Variables
Scroll down to Environment Variables section (under “Debug” tab).
Click Add or directly type in key-value pairs like this:
Save changes (Ctrl + S).
These variables will now be available at runtime when you debug the project.
Step 3: Use Them in Code
You already have the correct code
When you run or debug your project,
urlandkeywill automatically read values from the environment variables you added.Step 4 (Optional): Set System-wide Environment Variables
If you want these variables available outside Visual Studio, for example when running from command line:
Press Windows + R → type
sysdm.cpl→ Enter.Go to Advanced → Environment Variables.
Under User variables → click New.
Add:
Click OK and restart Visual Studio.
Tip (For ASP.NET / Web Projects)
If your project is an ASP.NET Core app, you can also use
appsettings.jsonand User Secrets instead of environment variables:Example:
And access them in C#: