Quickstart
This guide is dual-language. Pick the AppHost flavour you want and the rest of the page will follow your choice.
1. Scaffold an AppHost
Section titled “1. Scaffold an AppHost”mkdir MyAppHost && cd MyAppHostaspire initaspire add IEvangelist.Aspire.Hosting.Netlifyaspire add Aspire.Hosting.JavaScriptaspire init drops a minimal C# AppHost project. aspire add adds the
hosting integrations (and updates the AppHost’s .csproj).
mkdir MyAppHost && cd MyAppHostaspire initaspire add IEvangelist.Aspire.Hosting.Netlifyaspire add Aspire.Hosting.JavaScriptaspire init drops apphost.mts, aspire.config.json, package.json,
tsconfig.apphost.json, and a .aspire/modules/ folder for generated
TypeScript surface bindings (the CLI will prompt you to choose TypeScript).
aspire add registers each integration in aspire.config.json and regenerates
.aspire/modules/.
2. Wire up your frontend
Section titled “2. Wire up your frontend”Drop your built static frontend (e.g. an Astro dist/ folder) next to the
AppHost, then point at it:
using Aspire.Hosting;using Aspire.Hosting.JavaScript;
var builder = DistributedApplication.CreateBuilder(args);
// Optional: bind an auth token from configuration / user secrets.var authToken = builder.AddParameterFromConfiguration( "netlify-token", "NETLIFY_AUTH_TOKEN", secret: true);
builder.Pipeline.AddNetlifyDeployPipeline();
builder.AddJavaScriptApp("astro", "../astro") .PublishAsNetlifySite("dist", authToken);
builder.Build().Run();The single-argument overload of PublishAsNetlifySite is shorthand for
new NetlifyDeployOptions { Dir = "dist", NoBuild = true }. Use the full
NetlifyDeployOptions form when you need a Site, Message, or
Production flag.
// apphost.mtsimport { createBuilder } from "./.aspire/modules/aspire.mjs";
const builder = await createBuilder();
const authToken = await builder.addParameterFromConfiguration( "netlify-token", "NETLIFY_AUTH_TOKEN", { secret: true });
await builder.pipeline().addNetlifyDeployPipeline();
const astro = await builder.addJavaScriptApp("astro", "../astro");await astro .publishAsNetlifySite({ dir: "dist", noBuild: true }, { authToken });
await builder.build().run();Aspire 13.4 projects this integration’s [AspireExport]-annotated surface into
TypeScript through .aspire/modules/aspire.mjs. The publishAsNetlifySite,
addNetlifyDeployPipeline, withNpmCommand, and withNpmRunCommand
functions are generated automatically.
3. Run locally
Section titled “3. Run locally”aspire runAspire starts your frontend’s dev server alongside the dashboard. Browse to the dashboard URL printed in the terminal to inspect the resource tree.
4. Deploy
Section titled “4. Deploy”aspire deployThe pipeline:
- Resolves the Netlify CLI (auto-installs if missing).
- Resolves your auth token (parameter > env var >
ntl login). - Resolves the Netlify site ID (or creates a new site).
- Runs
netlify deploy ...and records the result.
See Configuration for the full list of options, and Authentication for the precedence rules.
Working samples
Section titled “Working samples”Both flavours have a runnable sample in the repo. Clone and run:
aspire run --apphost samples/Quickstart.AppHost/Quickstart.AppHost.csprojsamples/Quickstart.AppHost.TypeScript
aspire run --apphost samples/Quickstart.AppHost.TypeScript/apphost.mts