Build your first Aspire app
This quickstart uses the starter template that generates a C# AppHost. Youll create the solution, review the generated AppHost, and run it locally with Aspire.
Before you run through this quickstart, make sure youve installed the prerequisites and the Aspire CLI.
Install the Aspire VS Code extension if you want the same path in the editor: create or open the app, run Aspire: Configure launch.json file, then press F5F5F5F5F5F5 to start the AppHost and open the dashboard.
This starter template uses modern C#:
- Minimal APIs for lightweight HTTP APIs
- Blazor for interactive web UIs using C#
- Service defaults for shared configuration of observability and resilience
The following diagram shows the architecture of the sample app youre creating:
architecture-beta service api(logos:dotnet)[API service] service frontend(aspire:blazor)[Blazor frontend] frontend:L --> R:api
This quickstart uses the JavaScript starter template, which generates a TypeScript AppHost in apphost.mts. Youll create the solution, review the generated TypeScript AppHost, and run it locally with Aspire.
Before you run through this quickstart, make sure youve installed the prerequisites and the Aspire CLI.
Install the Aspire VS Code extension if you want the same path in the editor: create or open the app, run Aspire: Configure launch.json file, then press F5F5F5F5F5F5 to start the AppHost and open the dashboard.
This starter template combines a modern JavaScript stack:
- Express for building APIs with Node.js
- React for building user interfaces with JavaScript
- TypeScript for type-safe development across the entire stack
The following diagram shows the architecture of the sample app youre creating:
architecture-beta service api(logos:nodejs-icon)[API service] service frontend(logos:react)[React frontend] frontend:L --> R:api
Create a new app
Section titled Create a new appTo create your first Aspire application, use the Aspire CLI to generate a new solution from a template. These template include multiple projects, such as an API service, a web frontend, and an Aspire AppHost.
-
Create a new Aspire solution from a template:
Create a new aspire solutionaspire new aspire-starter -n AspireApp -o AspireAppThe template provides several projects, including an API service, web frontend, and AppHost.
The following flags are used in the command:
-n: specifies the name of the solution.-o: specifies the output directory.
For further CLI reference, see
aspire newcommand information.If prompted for additional selections, use the Up ArrowUp ArrowUp Arrow and Down ArrowDown ArrowDown Arrow keys to navigate the options. Press ReturnReturnEnterEnterEnterEnter to confirm your selection.
To create your first Aspire application, use the Aspire CLI to generate a new solution from a template. These template include multiple projects, such as an API service, a web frontend, and an Aspire AppHost.
-
Create a new Aspire solution from a template:
Create a new aspire solutionaspire new aspire-ts-starter -n aspire-app -o aspire-appThe template provides several projects, including an API service, web frontend, and AppHost.
The following flags are used in the command:
-n: specifies the name of the solution.-o: specifies the output directory.
For further CLI reference, see
aspire newcommand information.If prompted for additional selections, use the Up ArrowUp ArrowUp Arrow and Down ArrowDown ArrowDown Arrow keys to navigate the options. Press ReturnReturnEnterEnterEnterEnter to confirm your selection.
When prompted Would you like to configure AI agent environments for this project?, select
y. This sets up workspace configurations (such as Aspire skills and MCP server settings) for your project, enabling a richer experience with AI coding assistants. For more information, see Use AI coding agents and theaspire agent initreference.
Review the template code
Section titled Review the template code-
Examine the created template structure. The Aspire CLI creates a new folder with the name you provided in the current directory. This folder contains the solution file and several projects, including:
- AspireApp.sln
- DirectoryAspireApp.ApiService mock weather data API
- DirectoryProperties/
- appsettings.Development.json
- appsettings.json
- AspireApp.ApiService.csproj
- Program.cs
- DirectoryProperties/
- DirectoryAspireApp.AppHost dev-time orchestrator
- DirectoryProperties/
- appsettings.Development.json
- appsettings.json
- AspireApp.AppHost.csproj
- AppHost.cs
- DirectoryProperties/
- DirectoryAspireApp.ServiceDefaults
- Extensions.cs
- AspireApp.ServiceDefaults.csproj
- DirectoryAspireApp.Web ASP.NET Core Blazor frontend
- DirectoryProperties/
- Directorywwwroot/
- appsettings.Development.json
- appsettings.json
- AspireApp.Web.csproj
- Program.cs
- WeatherApiClient.cs
- DirectoryProperties/
This solution structure is based on the Aspire templates. If theyre not installed already, the CLI will install them for you.
-
Explore the AppHost code that orchestrates your app.
The AppHost is the heart of your Aspire application. It defines which services run, how they connect, and in what order they start. Lets look at the generated code:
AppHost.cs project-based orchestratorvar builder = DistributedApplication.CreateBuilder(args);var apiService = builder.AddProject<Projects.AspireApp_ApiService>("apiservice").WithHttpHealthCheck("/health");builder.AddProject<Projects.AspireApp_Web>("webfrontend").WithExternalHttpEndpoints().WithHttpHealthCheck("/health").WithReference(apiService).WaitFor(apiService);builder.Build().Run();Whats happening here?
CreateBuildercreates the distributed application builderAddProjectregisters your API service and web frontendWithReferenceconnects services. It injects the APIs URL as an environment variable and sets up service discovery so you can use service names instead of hardcoded URLsWaitForensures the API is healthy before starting the frontend, preventing connection errors from race conditionsWithHttpHealthCheckmonitors service health
Your application topology is defined in code, making it easy to understand, modify, and version control. Learn more about the AppHost.
-
Examine the created template structure. The Aspire CLI creates a new folder with the name you provided in the current directory. This folder contains the solution file and several projects, including:
- Directoryaspire-app/
- Directoryapi/ Express mock weather data API
- Directorysrc/
- index.ts
- instrumentation.ts
- package.json
- tsconfig.json
- Directorysrc/
- Directoryfrontend/ Vite + React web frontend
- Directorypublic/
- Aspire.png
- github.svg
- Directorysrc/
- App.css
- App.tsx
- index.css
- main.tsx
- vite-env.d.ts
- .dockerignore
- eslint.config.js
- index.html
- package.json
- tsconfig.json
- vite.config.ts
- Directorypublic/
- apphost.mts dev-time orchestrator
- Directory.aspire/
- Directorymodules/ generated TypeScript SDK
- Directorymodules/ generated TypeScript SDK
- aspire.config.json
- package.json
- tsconfig.apphost.json
- Directoryapi/ Express mock weather data API
This solution structure is based on the Aspire templates. If theyre not installed already, the CLI will install them for you.
- Directoryaspire-app/
-
Explore the AppHost code that orchestrates your app.
The AppHost is the heart of your Aspire application. It defines which services run, how they connect, and in what order they start. Lets look at the generated code:
apphost.mtsimport {createBuilder } from './.aspire/modules/aspire.mjs';function createBuilder(): IDistributedApplicationBuilderCreates a new distributed application builder
constbuilder = awaitconst builder: IDistributedApplicationBuildercreateBuilder();function createBuilder(): IDistributedApplicationBuilderCreates a new distributed application builder
// Run the Express API and expose its HTTP endpoint externally.constapp = awaitconst app: NodeAppResourcebuilderconst builder: IDistributedApplicationBuilder.addNodeApp("app", "./api", "src/index.ts")IDistributedApplicationBuilder.addNodeApp(name: string, appDirectory: string, scriptPath: string): NodeAppResourceAdds a node application to the application model. Node should be available on the PATH.
.withHttpEndpoint({ExecutableResource.withHttpEndpoint(options?: {port?: number;targetPort?: number;name?: string;env?: string;isProxied?: boolean;} | undefined): NodeAppResource (+1 overload)Adds an HTTP endpoint
env: "PORT" })env?: string | undefined.withExternalHttpEndpoints();ExecutableResource.withExternalHttpEndpoints(): NodeAppResourceMarks existing http or https endpoints on a resource as external.
// Run the Vite frontend after the API and inject the API URL for local proxying.constfrontend = awaitconst frontend: ViteAppResourcebuilderconst builder: IDistributedApplicationBuilder.addViteApp("frontend", "./frontend")IDistributedApplicationBuilder.addViteApp(name: string, appDirectory: string, options?: {runScriptName?: string;}): ViteAppResource (+1 overload)Adds a Vite app to the distributed application builder.
.withReference(ExecutableResource.withReference(source: EndpointReference | string | uri, options?: {connectionName?: string;optional?: boolean;name?: string;} | undefined): ViteAppResource (+1 overload)Adds a reference to another resource
app)const app: NodeAppResource.waitFor(ExecutableResource.waitFor(dependency: IResource | IResourceWithConnectionString, waitBehavior?: WaitBehavior): ViteAppResourceWaits for another resource to be ready
app);const app: NodeAppResource// Bundle the frontend build output into the API container for publish/deploy.awaitapp.const app: NodeAppResourcepublishWithContainerFiles(IContainerFilesDestinationResource.publishWithContainerFiles(source: IResourceWithContainerFiles, destinationPath: string): NodeAppResourceConfigures the resource to copy container files from the specified source resource during publishing.
frontend, "./static");const frontend: ViteAppResourceawaitbuilder.const builder: IDistributedApplicationBuilderbuild().IDistributedApplicationBuilder.build(): DistributedApplicationBuilds the distributed application
run();DistributedApplication.run(cancellationToken?: cancellationToken): voidRuns the distributed application
Whats happening here?
createBuildercreates the distributed application builderaddNodeAppadds a Node.js application (the Express API)addViteAppregisters your React frontendwithReferenceconnects the frontend to the API. It injects the APIs URL and sets up service discoverywaitForensures the API is running before starting the frontend, preventing connection errorspublishWithContainerFilesbundles the frontend for production deployment
This template uses a TypeScript AppHost. To learn more about how multi-language AppHosts work, see Multi-language architecture.
Your application topology is defined in code, making it easy to understand, modify, and version control. Learn more about the AppHost.
Run the app
Section titled Run the app-
Change to the output directory:
Change directoriescd ./AspireApp -
Call
aspire runto start dev-time orchestration:Run dev-time orchestrationaspire runWhen you run this command, the Aspire CLI:
- Automatically finds the AppHost
- Builds your solution
- Launches dev-time orchestration
Once the dashboard is ready, its URL (with a login token highlighted in the example output below) appears in your terminal. The dashboard provides a live, real-time view of your running resources and their current states.
Example outputFinding apphosts...AspireApp.AppHost/AspireApp.AppHost.csprojCreated settings file at 'aspire.config.json'.AppHost: AspireApp.AppHost/AspireApp.AppHost.csprojDashboard: https://localhost:17068/login?t=ea559845d54cea66b837dc0ff33c3bd3Logs: %USERPROFILE%/.aspire/cli/logs/apphost-13024-2025-10-31-19-40-58.logPress CTRL+C to stop the apphost and exit.For further CLI reference, see
aspire runcommand information. -
Explore the running distributed application. From the dashboard, open the
HTTPSendpoint from each resource.
[Aspire dashboard Resources page displaying two running resources: apiservice and webfrontend. Both are marked as Running with green check icons. The table lists columns for Name, State, Start time, Source, URLs, and Actions.]
To learn more, see Aspire dashboard overview.
-
Change to the output directory:
Change directoriescd ./aspire-app -
Call
aspire runto start dev-time orchestration:Run dev-time orchestrationaspire runWhen you run this command, the Aspire CLI:
- Automatically finds the AppHost
- Builds your solution
- Launches dev-time orchestration
Once the dashboard is ready, its URL (with a login token highlighted in the example output below) appears in your terminal. The dashboard provides a live, real-time view of your running resources and their current states.
Example outputFinding apphosts...apphost.mtsAppHost: apphost.mtsDashboard: https://localhost:17174/login?t=afb274c630f48b1c4ddfe139011c1cb7Logs: %USERPROFILE%/.aspire/logs/cli_20260318T134627_f31ad598.logPress CTRL+C to stop the apphost and exit.For further CLI reference, see
aspire runcommand information. -
Explore the running distributed application. From the dashboard, open the
HTTPSendpoint from each resource.
[Aspire dashboard Resources page displaying two running and two finished resources: app and frontend. Both app and frontend are marked as Running with green check icons while their installer resources show as Finished. The table lists columns for Name, State, Start time, Source, URLs, and Actions.]
To learn more, see Aspire dashboard overview.
Stop the app
Section titled Stop the app-
Stop the AppHost and close the dashboard by pressing +C+CControl + CCtrlCControl + CCtrlC in your terminal.
Stop dev-time orchestrationStopping Aspire.Congratulations! Youve created your first Aspire app.
You might be eager to deploy this app next and well show you how Aspire handles that, but youre probably also wondering: How do I test all this? Aspire doesnt just orchestrate locally and deploy, it also helps you test service and resource integrations too. Ready to dive in? Write your first test
-
Stop the AppHost and close the dashboard by pressing +C+CControl + CCtrlCControl + CCtrlC in your terminal.
Stop dev-time orchestrationStopping Aspire.Congratulations! Youve created your first Aspire app.
Ready to deploy? Follow the Deploy your first Aspire app TypeScript AppHost tutorial to ship your app to Docker Compose or Azure. Or, if youre wondering How do I test all this? Aspire helps you test service and resource integrations too. Write your first test
See also
Section titled See also- Having trouble? Check out our Troubleshooting guide for solutions to common problems.
- Prefer a GUI? The Aspire VS Code extension lets you create, run, and debug Aspire apps from VS Code.