A full-stack quotes board orchestrated by a single-file C# AppHost — the entire
dev-time orchestrator is one apphost.cs, with no .csproj and no Program.cs.
- Backend: ASP.NET Core Minimal API (
Api/) using theAspire.Npgsqlclient integration - Database: PostgreSQL (container, with a persistent data volume)
- Frontend: Vite + React (TypeScript), run via
AddViteApp - AppHost: single-file
apphost.cs(#:sdk/#:package/#:projectdirectives)
cd samples/dotnet-react-postgres
aspire runPrerequisites: Aspire CLI, Docker, the .NET 10 SDK, and Node 20+.
Aspire starts PostgreSQL, the API, and the Vite dev server, and opens the dashboard.
The React app is available from the web resource; it proxies /api to the API using
the endpoint Aspire injects via service discovery.
- A single-file
apphost.cs—#:sdk Aspire.AppHost.Sdk,#:packagefor the PostgreSQL and JavaScript hosting integrations, and#:project Api/Api.csprojto reference a real .NET project (surfaced as the generatedProjects.Apitype). AddPostgres(...).WithDataVolume().AddDatabase(...)for a persisted database.WithReference+WaitForto inject the connection string and order startup.AddViteAppfor a host-run Vite dev server, plusPublishWithContainerFilesto bake the built SPA into the API container foraspire publish.- The
Aspire.Npgsqlclient integration wiring upNpgsqlDataSource, OpenTelemetry, and health checks from the injectedConnectionStrings__quotesdb.
apphost.cs single-file C# AppHost (the orchestrator)
aspire.config.json points aspire at apphost.cs
apphost.run.json launch profiles (dashboard/OTLP ports)
Api/ ASP.NET Core Minimal API (quotes CRUD over Postgres)
ServiceDefaults/ shared OpenTelemetry / health / service-discovery wiring
frontend/ Vite + React SPA