# Use community extensions for PostgreSQL hosting

<Badge text="⭐ Community Toolkit" variant="tip" size="large" />

<Image
  src={postgresqlIcon}
  alt="PostgreSQL logo"
  width={100}
  height={100}
  class:list={'float-inline-left icon'}
  data-zoom-off
/>

The Aspire Community Toolkit PostgreSQL hosting extensions package provides extra functionality to the [Aspire.Hosting.PostgreSQL](https://www.nuget.org/packages/Aspire.Hosting.PostgreSQL) hosting package.

This package provides the following features:

- [Adminer](https://adminer.org/) management UI
- [DbGate](https://dbgate.org/) management UI

## Hosting integration

To get started with the Aspire Community Toolkit PostgreSQL hosting extensions, install the [CommunityToolkit.Aspire.Hosting.PostgreSQL.Extensions](https://www.nuget.org/packages/CommunityToolkit.Aspire.Hosting.PostgreSQL.Extensions) NuGet package in the app host project.

<InstallPackage packageName="CommunityToolkit.Aspire.Hosting.PostgreSQL.Extensions" />

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

```json title="aspire.config.json" ins={3}
{
  "packages": {
    "CommunityToolkit.Aspire.Hosting.PostgreSQL.Extensions": "*"
  }
}
```

## Add management UI

### DbGate management UI

To add the DbGate management UI to your PostgreSQL resource, call the `WithDbGate` method on the `PostgresServerResource` instance:

```csharp title="C# — 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...
```

```typescript title="TypeScript — apphost.mts"
import { createBuilder } from "./.aspire/modules/aspire.mjs";

const builder = await createBuilder();

const postgres = await builder.addPostgres("postgres");
await postgres.withDbGate();

const exampleProject = await builder.addProject(
    "example-project",
    "../ExampleProject/ExampleProject.csproj");
await 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.

### Adminer management UI

To add the Adminer management UI to your PostgreSQL resource, call the `WithAdminer` method on the `PostgresServerResource` instance:

```csharp title="C# — 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...
```

```typescript title="TypeScript — apphost.mts"
import { createBuilder } from "./.aspire/modules/aspire.mjs";

const builder = await createBuilder();

const postgres = await builder.addPostgres("postgres");
await postgres.withAdminer();

const exampleProject = await builder.addProject(
    "example-project",
    "../ExampleProject/ExampleProject.csproj");
await 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.

### Using both management UIs

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

```csharp title="C# — 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...
```

```typescript title="TypeScript — apphost.mts"
import { createBuilder } from "./.aspire/modules/aspire.mjs";

const builder = await createBuilder();

const postgres = await builder.addPostgres("postgres");
await postgres.withDbGate();
await postgres.withAdminer();

const exampleProject = await builder.addProject(
    "example-project",
    "../ExampleProject/ExampleProject.csproj");
await exampleProject.withReference(postgres);

// After adding all resources, run the app...
```

## See also

- [Adminer documentation](https://www.adminer.org/)
- [DbGate documentation](https://dbgate.org/)
- [PostgreSQL integration](/integrations/databases/postgres/postgres-host/)
- [Aspire Community Toolkit](https://github.com/CommunityToolkit/Aspire)
- [Aspire integrations overview](/integrations/overview/)
- [Aspire GitHub repo](https://github.com/microsoft/aspire)