Skip to content

Conversation

@fgilde
Copy link

@fgilde fgilde commented Jan 20, 2026

Closes #417

Overview

This PR adds a complete Supabase stack integration for .NET Aspire, enabling local development with full Supabase functionality.

Features

  • Full Supabase Stack: PostgreSQL, Auth (GoTrue), REST API (PostgREST), Storage, Kong API Gateway, Studio Dashboard, Postgres-Meta, and Edge Functions
  • Fluent Configuration API: Configure each component individually via ConfigureAuth(), ConfigureDatabase(), ConfigureStorage(), etc.
  • Project Sync: Synchronize schema, data, storage buckets, and edge functions from remote Supabase projects
  • Local Migrations: Apply local SQL migration files
  • Edge Functions: Support for local Deno-based edge functions
  • Pre-registered Users: Create development users on startup
  • Dashboard Commands: Add custom commands to the Aspire dashboard (e.g., "Clear All Data")

Usage

var builder = DistributedApplication.CreateBuilder(args);

var supabase = builder.AddSupabase("supabase")
    .ConfigureAuth(auth => auth
        .WithSiteUrl("http://localhost:3000")
        .WithAutoConfirm(true))
    .ConfigureStorage(storage => storage
        .WithFileSizeLimit(100_000_000))
    .WithMigrations("<path_to_migrations>")
    .WithEdgeFunctions("<path_to_functions>");

builder.Build().Run();

PR Checklist

  • Created a feature/dev branch in your fork (vs. submitting directly from a commit on main)
  • Based off latest main branch of toolkit
  • PR doesn't include merge commits (always rebase on top of our main, if needed)
  • New integration
    • Docs are written
    • Added description of major feature to project description for NuGet package (4000 total character limit, so don't push entire description over that)
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Contains NO breaking changes
  • Every new API (including internal ones) has full XML docs
  • Code follows all style conventions

Other information

Tests

  • 44 unit tests covering resource creation, configuration, and container setup
  • Tests run sequentially via [Collection("Supabase")] to avoid file locking issues during parallel execution

Example Project

  • Complete AppHost example demonstrating all configuration options
  • ServiceDefaults project with standard OpenTelemetry/HealthChecks setup

Container Images Used

  • supabase/postgres - PostgreSQL with Supabase extensions
  • supabase/gotrue - Authentication service
  • postgrest/postgrest - REST API
  • supabase/storage-api - File storage
  • kong - API Gateway
  • supabase/postgres-meta - Database metadata API
  • supabase/studio - Dashboard UI
  • supabase/edge-runtime - Edge Functions runtime

Copilot AI review requested due to automatic review settings January 20, 2026 15:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a complete Supabase stack integration for .NET Aspire, enabling local development with full Supabase functionality. The integration goes beyond the original issue's scope by providing not just PostgreSQL, but a complete Supabase stack including Auth (GoTrue), REST API (PostgREST), Storage, Kong API Gateway, Studio Dashboard, Postgres-Meta, and Edge Functions support.

Changes:

  • Complete Supabase stack with 8+ containerized services working together
  • Fluent configuration API for each Supabase component
  • Project synchronization from remote Supabase instances
  • Local migrations and Edge Functions support
  • 44 comprehensive unit tests

Reviewed changes

Copilot reviewed 39 out of 39 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/CommunityToolkit.Aspire.Hosting.Supabase/*.cs Core implementation with resources, builders, and extensions
src/CommunityToolkit.Aspire.Hosting.Supabase/Sync/*.cs Remote project synchronization functionality
src/CommunityToolkit.Aspire.Hosting.Supabase/Helpers/*.cs SQL generation and Edge Function routing
tests/CommunityToolkit.Aspire.Hosting.Supabase.Tests/*.cs Comprehensive test coverage (44 tests)
examples/supabase/* Complete AppHost example with ServiceDefaults
README.md, CommunityToolkit.Aspire.slnx Documentation and solution integration

@fgilde
Copy link
Author

fgilde commented Jan 20, 2026

@fgilde please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@dotnet-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@dotnet-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@dotnet-policy-service agree company="Microsoft"

Contributor License Agreement

@dotnet-policy-service agree

@axies20
Copy link
Contributor

axies20 commented Jan 24, 2026

Can be added client for supabase that will automatically initialize

var url = Environment.GetEnvironmentVariable("SUPABASE_URL");
var key = Environment.GetEnvironmentVariable("SUPABASE_KEY");
var options = new Supabase.SupabaseOptions
{
    AutoConnectRealtime = true
};
var supabase = new Supabase.Client(url, key, options);
await supabase.InitializeAsync();

something like that:

builder.AddSupabae("SupaBaseName");

Copy link
Member

@aaronpowell aaronpowell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there are the bones of a solid integration taking shape here but there's a bit of work that needs to be done before it would fit into the community toolkit.

I've left quite a few comments throughout the PR (although I didn't add them to all the resource classes as there was a set of repeated comments on all of them).

The one thing that I don't think this integration is currently doing well enough is leveraging the Aspire app model design around resource creation and management, and that will need addressing before it could be merged in.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you remove this file.

Comment on lines +22 to +23
.WithMigrations("<path_to_migrations_folder>")
.WithEdgeFunctions("<path_to_edge_functions_folder>");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

obviously this is intended for example purposes, but will this have a problem when running the example app? Would it be better to leave that for the docs instead?

Comment on lines +12 to +21
.ConfigureAuth(auth => auth
.WithSiteUrl("http://localhost:3000")
.WithAutoConfirm(true)
.WithAnonymousUsers(true))
.ConfigureStorage(storage => storage
.WithFileSizeLimit(100_000_000) // 100MB
.WithImageTransformation(true))
.ConfigureDatabase(db => db
.WithPassword("your-secure-password")
.WithPort(54322))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From an API design perspective, this doesn't align with Aspire, each of those parts should be treated as resources that you manage:

superbase.WithAuth() // pass any required args
  .WithSiteUrl(...)
  .WithAutoConfirm(true)
  .WithAnonymousUsers(true);

superbase.WithStorage(fileSizeLimit: 100_000_000)
  .WithImageTransformation(true);

var database = superbase.WithDatabase(password: passwordResource)
  .WithPort(54322);

Action<IResourceBuilder<SupabaseAuthResource>> configure)
{
var stack = builder.Resource;
if (stack.Auth == null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (stack.Auth == null)
if (stack.Auth is null)

Action<IResourceBuilder<SupabaseDatabaseResource>> configure)
{
var stack = builder.Resource;
if (stack.Database == null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (stack.Database == null)
if (stack.Database is null)

}
catch (Exception ex)
{
Console.WriteLine($"[Supabase Sync] ERROR: {ex.Message}");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a logger not Console.

/// <summary>
/// Service for synchronizing data from an online Supabase project to the local development environment.
/// </summary>
internal static class SyncService
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My initial take on this is that it should be a resource that Aspire manages rather than just some arbitrary code that is run during the app host.

Conceptually, it's similar to an installer provided by npm, yarn, python, etc. and we should design it that way.


namespace CommunityToolkit.Aspire.Hosting.Supabase.Tests;

[Collection("Supabase")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use collections.


namespace CommunityToolkit.Aspire.Hosting.Supabase.Tests;

[Collection("Supabase")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use collections

@@ -0,0 +1,6 @@
namespace CommunityToolkit.Aspire.Hosting.Supabase.Tests;

[CollectionDefinition("Supabase", DisableParallelization = true)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use collections.

Copy link
Member

@aaronpowell aaronpowell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there are the bones of a solid integration taking shape here but there's a bit of work that needs to be done before it would fit into the community toolkit.

I've left quite a few comments throughout the PR (although I didn't add them to all the resource classes as there was a set of repeated comments on all of them).

The one thing that I don't think this integration is currently doing well enough is leveraging the Aspire app model design around resource creation and management, and that will need addressing before it could be merged in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Add Supabase integration

3 participants