Skip to content
DocsTry Aspire
DocsTry

JavaScript monorepo hosting extensions

⭐ Community Toolkit Node.js logo

The 📦 CommunityToolkit.Aspire.Hosting.JavaScript.Extensions package adds Nx and Turborepo monorepo support to the official 📦 Aspire.Hosting.JavaScript integration. Use the official package for individual Node.js, Vite, Next.js, and Bun apps; use this Community Toolkit package when an app belongs to an Nx or Turborepo workspace.

Start with an existing Nx or Turborepo workspace. Pass the workspace root as workingDirectory, then pass the Nx project name or Turborepo package name to AddApp / addApp. For Turborepo, the optional filter selects the package to run.

The extensions add:

  • AddNxApp / addNxApp for an Nx workspace.
  • AddTurborepoApp / addTurborepoApp for a Turborepo workspace.
  • AddApp / addApp for apps within those workspaces.
  • WithNpm, WithYarn, WithPnpm, and WithBun to select the workspace package manager.
  • WithPackageManagerLaunch / withPackageManagerLaunch to launch the workspace through the selected package manager.
  • WithMappedEndpointPort / withMappedEndpointPort to pass an Aspire endpoint’s allocated port to a JavaScript app.
Aspire CLI — Add CommunityToolkit.Aspire.Hosting.JavaScript.Extensions package
aspire add communitytoolkit-javascript-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-javascript-extensions (CommunityToolkit.Aspire.Hosting.JavaScript.Extensions)
> Other results listed as selectable options...

AddNxApp / addNxApp models the workspace. Add each runnable project with AddApp / addApp, then decorate that child app with the official JavaScript resource APIs it needs.

AppHost.cs
var builder = DistributedApplication.CreateBuilder(args);
var nx = builder.AddNxApp("nx-workspace", "../nx-demo")
.WithNpm(install: true)
.WithPackageManagerLaunch();
nx.AddApp("blog")
.WithHttpEndpoint(env: "PORT")
.WithMappedEndpointPort();
builder.Build().Run();

Use AddTurborepoApp / addTurborepoApp for a Turborepo workspace. The optional filter selects the workspace package to run.

AppHost.cs
var builder = DistributedApplication.CreateBuilder(args);
var turbo = builder.AddTurborepoApp("turborepo", "../turborepo-demo")
.WithPnpm(install: true)
.WithPackageManagerLaunch();
turbo.AddApp("web", filter: "web")
.WithHttpEndpoint(env: "PORT")
.WithMappedEndpointPort();
builder.Build().Run();