Skip to content
DocsTry Aspire
DocsTry

Use community extensions for PostgreSQL hosting

⭐ Community Toolkit PostgreSQL logo

The Aspire Community Toolkit PostgreSQL hosting extensions package provides extra functionality to the Aspire.Hosting.PostgreSQL hosting package.

This package provides the following features:

  • Adminer management UI
  • DbGate management UI
  • dbx management UI
  • Flyway migration and repair commands

To get started with the Aspire Community Toolkit PostgreSQL hosting extensions, install the CommunityToolkit.Aspire.Hosting.PostgreSQL.Extensions NuGet package in the app host project.

Aspire CLI — Add CommunityToolkit.Aspire.Hosting.PostgreSQL.Extensions package
aspire add communitytoolkit-postgresql-extensions

The Aspire CLI is interactive, be sure to select the appropriate search result when prompted:

Aspire CLI — Example output prompt
Select an integration to add:
> communitytoolkit-postgresql-extensions (CommunityToolkit.Aspire.Hosting.PostgreSQL.Extensions)
> Other results listed as selectable options...

For TypeScript AppHosts, add the Community Toolkit PostgreSQL extensions package to aspire.config.json:

aspire.config.json
{
"packages": {
"CommunityToolkit.Aspire.Hosting.PostgreSQL.Extensions": "*"
}
}

To add the DbGate management UI, decorate the official PostgresServerResource builder with WithDbGate / withDbGate:

AppHost.cs
var builder = DistributedApplication.CreateBuilder(args);
var postgres = builder.AddPostgres("postgres")
.WithDbGate();
builder.AddProject<Projects.ExampleProject>()
.WithReference(postgres);
// After adding all resources, run the app...

This adds a new DbGate resource to the app host which is available from the Aspire dashboard. DbGate is a comprehensive database management tool that provides a web-based interface for managing your PostgreSQL databases.

To add the Adminer management UI, decorate the official PostgresServerResource builder with WithAdminer / withAdminer:

AppHost.cs
var builder = DistributedApplication.CreateBuilder(args);
var postgres = builder.AddPostgres("postgres")
.WithAdminer();
builder.AddProject<Projects.ExampleProject>()
.WithReference(postgres);
// After adding all resources, run the app...

This adds a new Adminer resource to the app host which is available from the Aspire dashboard. Adminer is a lightweight database management tool that provides a simple web interface for database operations.

You can use both management UIs together on the same PostgreSQL resource:

AppHost.cs
var builder = DistributedApplication.CreateBuilder(args);
var postgres = builder.AddPostgres("postgres")
.WithDbGate()
.WithAdminer();
builder.AddProject<Projects.ExampleProject>()
.WithReference(postgres);
// After adding all resources, run the app...

dbx is a lightweight, web-based database client and an alternative management UI to DbGate and Adminer. Use WithDbx / withDbx to add a dbx child resource configured for the PostgreSQL server:

AppHost.cs
var builder = DistributedApplication.CreateBuilder(args);
var postgres = builder.AddPostgres("postgres")
.WithDbx();
builder.Build().Run();

The C# overload accepts an optional container configuration callback and containerName. The TypeScript binding accepts optional containerName and imageTag values.

Flyway decorators apply to an official PostgresDatabaseResource, not the PostgreSQL server resource.

In C#, add a Flyway resource and pass it to WithFlywayMigration. In TypeScript, withFlywayMigration creates the Flyway resource from its name and migration scripts path.

Place versioned SQL files such as V1__init.sql in ./migrations; Flyway discovers them by its versioned migration naming convention.

AppHost.cs
var builder = DistributedApplication.CreateBuilder(args);
var migrations = builder.AddFlyway("migrations", "./migrations");
var postgres = builder.AddPostgres("postgres");
var database = postgres.AddDatabase("appdb")
.WithFlywayMigration(migrations);
migrations.WaitFor(database);
var api = builder.AddProject<Projects.Api>("api")
.WithReference(database)
.WaitFor(database)
.WaitForCompletion(migrations);
builder.Build().Run();

WithFlywayMigration configures the Flyway connection arguments and migrate command; it doesn’t add resource ordering. In the C# example, migrations.WaitFor(database) ensures Flyway starts only after PostgreSQL is ready, and api.WaitForCompletion(migrations) gates the API on the migration resource’s completion.

The TypeScript overload creates and configures the Flyway resource internally, but it doesn’t add a waitFor relationship or return the Flyway resource builder. The TypeScript binding therefore can’t express the C# example’s startup and completion dependencies for that internally created resource.

Use WithFlywayRepair(migrations) in C# or withFlywayRepair("flyway-repair", "./migrations") in TypeScript when you need Flyway’s repair command instead of migrate. The same ordering behavior and TypeScript limitation apply.