What's new#
Supabase.Extensions.DependencyInjection is a new package that provides an easier way to plug the Supabase .NET SDK into your application. It exposes a new method on IServiceCollection called AddSupabase which registers the main client and all sub-clients:
_10builder.Services.AddSupabase(_10 supabaseUrl: "https://xyz.supabase.co",_10 supabaseKey: builder.Configuration["Supabase:Key"]!,_10 configureOptions: options =>_10 {_10 options.AutoConnectRealtime = true;_10 options.PostgrestRetry = new RetryOptions { MaxRetries = 3 };_10 });
It registers all clients (Supabase.Client, IGotrueClient, IPostgrestClient, IStorageClient, IFunctionsClient, IRealtimeClient) with a scoped lifecycle, so you can resolve them wherever you need them:
_10app.MapGet("/movies", async (IPostgrestClient postgrest) =>_10 await postgrest.Table<Movie>().Get());
The package is available on NuGet:
_10dotnet add package Supabase.Extensions.DependencyInjection
Why it matters#
You can always register all the required clients in IServiceCollection yourself. This package simply does it all for you and removes boilerplate from your codebase.