Skip to content

Quickstart

This guide is dual-language. Pick the AppHost flavour you want and the rest of the page will follow your choice.

Terminal window
mkdir MyAppHost && cd MyAppHost
aspire init
aspire add IEvangelist.Aspire.Hosting.Netlify
aspire add Aspire.Hosting.JavaScript

aspire init drops a minimal C# AppHost project. aspire add adds the hosting integrations (and updates the AppHost’s .csproj).

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.

Terminal window
aspire run

Aspire starts your frontend’s dev server alongside the dashboard. Browse to the dashboard URL printed in the terminal to inspect the resource tree.

Terminal window
aspire deploy

The pipeline:

  1. Resolves the Netlify CLI (auto-installs if missing).
  2. Resolves your auth token (parameter > env var > ntl login).
  3. Resolves the Netlify site ID (or creates a new site).
  4. Runs netlify deploy ... and records the result.

See Configuration for the full list of options, and Authentication for the precedence rules.

Both flavours have a runnable sample in the repo. Clone and run:

samples/Quickstart.AppHost

Terminal window
aspire run --apphost samples/Quickstart.AppHost/Quickstart.AppHost.csproj