Skip to content

Document JavaScript framework publish methods (PublishAsStaticWebsite, PublishAsNodeServer, PublishAsNpmScript, AddNextJsApp) #673

Closed

Description

Summary

PR microsoft/aspire#15736 added new JavaScript publish methods and AddNextJsApp to Aspire.Hosting.JavaScript. We need a comprehensive article covering how to use JavaScript frameworks with Aspire — from local development through deployment.

Proposed article: "Using JavaScript frameworks with Aspire"

Topics to cover

1. Framework categories and which publish method to use

Category Publish Method Frameworks Why
Static SPAs PublishAsStaticWebsite Vite, React, Vue, Angular, Astro (static) Build outputs static dist/ files, served by YARP
Self-contained Node servers PublishAsNodeServer SvelteKit, TanStack Start Build bundles everything, runs with node server.js
Node servers needing node_modules PublishAsNpmScript Nuxt, Remix, Astro SSR Runtime imports from node_modules
Next.js AddNextJsApp Next.js Standalone output with 3-COPY Dockerfile pattern

2. Local development (run mode)

  • AddViteApp vs AddJavaScriptApp vs AddNodeApp vs AddNextJsApp — when to use each
  • Port binding: how Aspire passes --port (Vite) vs -p (Next.js) to dev servers
  • Package managers: WithNpm(), WithYarn(), WithPnpm(), WithBun() — composable with all methods
  • WithOtlpExporter() — getting telemetry from JS apps into the Aspire dashboard

3. Publishing / Deployment

  • PublishAsStaticWebsite — YARP-based static file serving
    • Default behavior (SPA fallback, dist/ output)
    • outputPath for Angular (dist/browser) and other frameworks
    • API reverse-proxy with apiPath/apiTarget (solves CORS for SPAs)
    • StripPrefix option
    • TargetEndpointName for specific endpoint selection
  • PublishAsNodeServer — self-contained Node.js server
    • entryPoint and outputPath parameters
    • Framework-specific examples (SvelteKit build/index.js, TanStack .output/server/index.mjs)
  • PublishAsNpmScript — runtime with node_modules
    • When to use (Nuxt's useAsyncData, Remix's react-router-serve, Astro SSR's @astrojs/*)
    • startScriptName and runScriptArguments
  • AddNextJsApp — Next.js standalone
    • output: "standalone" in next.config.ts (required)
    • public/ directory requirement
    • Deploy-time validation and DisableBuildValidation()

4. Framework-specific gotchas

Based on aspire-js-chaos POC validation:

  • Nuxt: Pages must be under app/pages/, env vars need NUXT_ prefix for runtimeConfig
  • Astro SSR: Must set export const prerender = false, use process.env not import.meta.env
  • SvelteKit: Requires @sveltejs/adapter-node (default adapter-auto doesn't produce a deployable artifact)
  • Next.js: Must set output: "standalone", needs public/ directory
  • Angular: Uses dist/browser output path, not dist

5. Advanced scenarios

  • Custom base images via WithDockerfileBaseImage
  • PublishWithContainerFiles for embedding static files into a .NET server (existing pattern)
  • How to choose between PublishAsStaticWebsite + API proxy vs PublishWithContainerFiles

Related

Activity

  1. added this to the 13.3 milestone on Apr 4, 2026
  2. davidfowl commented on Apr 4, 2026

    @davidfowl
    ContributorAuthor

    I have follow up changes to make so ths is not urgent.

  3. IEvangelist commented on Jun 2, 2026

    @IEvangelist
    Member

    Triage → David Pine (@IEvangelist)

    Large new article spanning PublishAsStaticWebsite, PublishAsNodeServer, PublishAsNpmScript, and AddNextJsApp (from microsoft/aspire#15736). This is a "use JS frameworks with Aspire" tutorial that goes from dev → publish → deploy. Scope:

    • New article under languages-and-runtimes/javascript/ (or wherever the JS IA lives).
    • Per-method walkthrough with one canonical sample per method.
    • Cross-link from the existing JS integration page and from deployment/.

    Better to scope and outline first, then hand the per-section drafting to Copilot. Suggest splitting into 4 issues (one per method) once the outline lands.

  4. IEvangelist commented on Oct 18, 2026

    @IEvangelist
    Member

    Addressed by #765, #767, and #932. The content is now on main, so closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancement

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions