When you create a TypeScript AppHost with aspire new, the CLI scaffolds a project with the following structure:
Directorymy-apphost/
Directory.aspire/modules/ Generated TypeScript SDK (do not edit)
aspire.mts
base.mts
transport.mts
apphost.mts Your AppHost entry point
aspire.config.json Aspire configuration
package.json
tsconfig.apphost.json
When you run aspire init --language typescript in an existing JavaScript or TypeScript app that already has a root package.json, Aspire creates the AppHost in a nested aspire-apphost/ package. The root aspire.config.json points to aspire-apphost/apphost.mts, and the root package.json gets Aspire delegate scripts so the existing app package keeps its own module and toolchain settings:
Directorymy-existing-app/
Directoryaspire-apphost/
Directory.aspire/modules/ Generated TypeScript SDK (do not edit)
aspire.mts
base.mts
transport.mts
apphost.mts Your AppHost entry point
package.json
tsconfig.apphost.json
aspire.config.json Aspire configuration
package.json Existing app package with Aspire delegate scripts
Use aspire add from the AppHost root to add hosting integrations. The CLI adds the package to the packages section, restores AppHost dependencies, and regenerates the TypeScript SDK in .aspire/modules/:
Add an integration
aspireaddredis
This updates aspire.config.json so the package is restored the next time the AppHost runs:
aspire.config.json
{
"packages":{
"Aspire.Hosting.JavaScript":"13.6.0",
"Aspire.Hosting.Redis":"13.6.0"
}
}
Run aspire restore when you want to regenerate .aspire/modules/ without starting the AppHost, such as after switching branches, updating package versions, or preparing a CI job:
The .aspire/modules/ directory under the AppHost root contains the generated TypeScript SDK. It’s created and updated automatically by the Aspire CLI — do not edit these files.
File
Purpose
aspire.mts
Generated typed API for all your installed integrations
base.mts
Base types and handle infrastructure
transport.mts
JSON-RPC transport layer
The SDK regenerates when:
You run aspire add to add or update an integration
You run aspire run or aspire start and the package list has changed
TypeScript AppHosts read configuration from JSON files that live next to apphost.mts. Add an appsettings.json file to your AppHost and Aspire loads it into the AppHost’s configuration at startup. You read the effective values in apphost.mts through the builder’s configuration accessor.
Start with base settings as plain JSON. Settings can be flat, like message, or grouped in nested objects, like deployment.region. Keys are matched case-insensitively, so camelCase fits naturally in a TypeScript project:
appsettings.json
{
"message":"From appsettings.json",
"deployment":{
"region":"westus"
}
}
With only appsettings.json present, read a flat value by its key. For a nested value, use : to separate each level of the JSON path. The getConfigValue() method returns null if the key isn’t found:
Aspire always loads appsettings.json first, then layers appsettings.{Environment}.json on top. The value passed to --environment replaces {Environment} in the filename. For example, --environment Development loads appsettings.Development.json, while --environment Production loads appsettings.Production.json.
The environment-specific file overrides matching values from appsettings.json. The merged configuration is available through getConfiguration() when the AppHost starts.
The Aspire CLI supports the following package managers at the AppHost root — the directory that contains your apphost.mts and aspire.config.json. The CLI selects between them by inspecting package manager signals, including the packageManager field in package.json, lock files, and package manager configuration in the AppHost root.
Package manager
Detection signals
Version expectation
npm
packageManager, package-lock.json, or no other signal
npm 10 or later; npm is the default
pnpm
packageManager or pnpm-lock.yaml
pnpm 10 or later
Yarn
packageManager, yarn.lock, .yarnrc.yml, or .yarn/
Yarn 4 or later (Berry)
Bun
packageManager, bun.lock, or bun.lockb
Bun 1.2 or later
Deno
packageManager, deno.lock, deno.json, or deno.jsonc
Deno 2 or later
Yarn Classic (v1)
yarn.lock with # yarn lockfile v1 or packageManager with yarn@1.x
Not supported
This policy governs the AppHost root only. Apps the AppHost orchestrates — for example, a Node.js service added with addNodeApp, a Bun guest app, or a workspace package — can use any package manager their own tooling requires; they are independent of the AppHost-root toolchain.
Aspire end-to-end tests cover TypeScript AppHosts with representative packageManager pins such as npm@10.0.0, pnpm@10.0.0, yarn@4.14.1, and bun@1.2.0. These tested versions are representative points within the supported ranges, not the only versions you can use.
When using Node.js, TypeScript AppHosts target the engine range that aspire init writes into the scaffolded AppHost package.json. Deno and Bun run the AppHost with their own runtimes:
package.json — supported engines.node
{
"engines":{
"node":"^20.19.0 || ^22.13.0 || >=24"
}
}
The supported ranges are:
Node.js 20.19+ — supported.
Node.js 22.13+ (22.x LTS) — supported.
Node.js 24.x and later — supported by the scaffolded engines.node constraint.
Older Node.js versions are not supported. Package managers may enforce engines.node on install (for example, pnpm does by default, while npm only does when engine-strict is configured), so unsupported runtimes are best treated as blocked even when a given toolchain only warns.
The Aspire CLI automatically detects your TypeScript AppHost toolchain and adjusts install and run commands accordingly. The following toolchains are supported: npm (default), Bun, Yarn, pnpm, and Deno.
Detection follows the supported AppHost-root package managers policy. The CLI resolves the toolchain by inspecting the AppHost directory and its parent directories (up to eight levels). It checks, in order:
The packageManager field in package.json — for example, "packageManager": "pnpm@10.0.0".
Toolchain markers: bun.lock or bun.lockb → Bun; pnpm-lock.yaml → pnpm; yarn.lock, .yarnrc.yml, or a .yarn/ directory → Yarn; deno.lock, deno.json, or deno.jsonc → Deno.
If nothing is found, npm is used as the default.
The search walks up parent directories, so a workspace-level packageManager setting or lockfile is picked up automatically by nested AppHosts.
The recommended way to pin the toolchain is with the packageManager field in package.json, which Aspire uses for toolchain detection. This field is also used by Node.js Corepack for package managers such as Yarn and pnpm:
Install Deno 2 or later and select it with a Deno configuration file, lockfile, or a packageManager entry such as "deno@2.0.0". The generated AppHost module and resource APIs stay the same. This is distinct from hosting a Deno application: addDenoApp models a guest resource and doesn’t choose the AppHost runtime.
Aspire restores dependencies with deno install and validates the AppHost with deno check. Deno uses its own configuration rather than tsconfig.apphost.json. Watch mode uses Deno’s native watcher and checks types on every restart, without tsx or nodemon. The CLI rejects Deno 1.x.
The aspire doctor command checks that the selected toolchain executable is available. If Bun, Yarn, pnpm, or Deno is detected but not installed, the command reports an error with install guidance. For Deno, it also checks the Deno 2 minimum version.
TypeScript AppHosts support fluent chaining for builder methods — for example, builder.addContainer(...).withReference(...) — so you can build resource graphs in a compact, readable style. Starting with Aspire 13.4, the generated SDK extends this to all generated async methods that return a chainable wrapper type: environment helpers, execution-context queries, and endpoint property accessors.
Previously, using these methods required splitting the chain or using a double await:
apphost.ts (before)
// Two separate awaits were needed when chaining through async wrapper-returning methods
Before starting a TypeScript AppHost, the Aspire CLI runs tsc --noEmit, or deno check for Deno, to check for type errors to prevent the dashboard and resources from starting in a partially broken state. If your AppHost has TypeScript compile errors, aspire run and aspire publish stop before the AppHost launches and display the diagnostic output:
apphost.mts(22,7): error TS2322: Type 'string' is not assignable to type 'number'.
When you use aspire run in watch mode with a nodemon-based toolchain, TypeScript validation is embedded in the restart command. The watcher can still start even if there are initial type errors — it will recover automatically as you edit and save files that fix the errors. Deno instead uses its native --watch --check flow.
When you run a TypeScript AppHost with an HTTPS launch profile, the Aspire CLI
needs a trusted HTTPS development certificate to be present on your machine.
Unlike .NET AppHost users who typically have the .NET SDK on their PATH, TypeScript
AppHost users may not have dotnet available, so the Aspire CLI provides its own
certificate management commands.
If you see an error similar to the following when running aspire run:
Unable to configure HTTPS endpoint. No server certificate was specified, and the default
developer certificate could not be found or is out of date. To generate and trust a
developer certificate run 'aspire certs trust'. For more information on configuring
HTTPS see https://aspire.dev/docs/.
Run the following command to create and trust the development certificate:
Aspire CLI
aspirecertstrust
Trusting the certificate for outbound TLS connections
When your AppHost code opens TLS connections to Aspire-managed resources at runtime (for example, connecting directly to the dashboard’s OTLP endpoint from custom AppHost logic), the Aspire CLI ensures Node.js trusts the same development certificate that the Developer Control Plane (DCP) uses. The CLI exports the trusted development certificate into a content-addressed PEM cache under the Aspire home directory (ASPIRE_HOME), and Node.js is configured to trust that bundle through the NODE_EXTRA_CA_CERTS environment variable.
If you’ve already set NODE_EXTRA_CA_CERTS for your own certificates, the CLI preserves your value by generating a combined bundle that includes both your certificates and the Aspire development certificate, rather than overwriting your setting.
For a Deno AppHost, Aspire uses DENO_CERT for the trusted PEM bundle, preserving an existing bundle by combining it with Aspire’s development certificate. This works across Deno 2 releases; NODE_EXTRA_CA_CERTS support in Deno starts only with Deno 2.8.
See Certificate configuration for details
on HTTPS certificate management in Aspire, including Linux-specific setup.
When the Aspire CLI runs a TypeScript (Node.js) AppHost, it contacts a managed server to generate the TypeScript SDK. That server loads NuGet-restored packages (Aspire.Hosting.JavaScript, Aspire.TypeSystem, and related assemblies). If the CLI version and the SDK version in aspire.config.json differ in major, minor, patch, or prerelease identifiers (excluding build metadata), code generation can fail.
Before starting the AppHost, the CLI compares its built-in SDK version against the SDK version used for code generation (the sdk.version value in aspire.config.json, or the target version during aspire update). When the CLI is older than the SDK, the CLI prints a warning:
⚠ The installed Aspire CLI version (<CLI_VERSION>) differs from the Aspire SDK
version (<SDK_VERSION>) used for code generation. If you run into errors,
update the Aspire CLI to match or exceed the SDK version.
A newer CLI running an AppHost pinned to an older SDK doesn’t produce the warning, and build metadata is ignored. The AppHost still starts after the warning. If codegen succeeds, no further action is required. If codegen fails, update the CLI with aspire update --self.
Run aspire update to update the packages in aspire.config.json to match the installed CLI version, or reinstall the CLI to match the SDK version already in use: