-
Notifications
You must be signed in to change notification settings - Fork 65
Document JavaScript framework publish methods (PublishAsStaticWebsite, PublishAsNodeServer, PublishAsNpmScript, AddNextJsApp) #673
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or request
Milestone
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)
AddViteAppvsAddJavaScriptAppvsAddNodeAppvsAddNextJsApp— 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) outputPathfor Angular (dist/browser) and other frameworks- API reverse-proxy with
apiPath/apiTarget(solves CORS for SPAs) StripPrefixoptionTargetEndpointNamefor specific endpoint selection
- Default behavior (SPA fallback,
PublishAsNodeServer— self-contained Node.js serverentryPointandoutputPathparameters- Framework-specific examples (SvelteKit
build/index.js, TanStack.output/server/index.mjs)
PublishAsNpmScript— runtime with node_modules- When to use (Nuxt's
useAsyncData, Remix'sreact-router-serve, Astro SSR's@astrojs/*) startScriptNameandrunScriptArguments
- When to use (Nuxt's
AddNextJsApp— Next.js standaloneoutput: "standalone"innext.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 needNUXT_prefix forruntimeConfig - Astro SSR: Must set
export const prerender = false, useprocess.envnotimport.meta.env - SvelteKit: Requires
@sveltejs/adapter-node(defaultadapter-autodoesn't produce a deployable artifact) - Next.js: Must set
output: "standalone", needspublic/directory - Angular: Uses
dist/browseroutput path, notdist
5. Advanced scenarios
- Custom base images via
WithDockerfileBaseImage PublishWithContainerFilesfor embedding static files into a .NET server (existing pattern)- How to choose between
PublishAsStaticWebsite+ API proxy vsPublishWithContainerFiles
Related
- Feature PR: Add JavaScript publish methods, AddNextJsApp, and switch to YARP aspire#15736
- Issue: JavaScript/Vite Apps Are Always Build-Only - No Way to Deploy as Standalone Services aspire#12697
- POC repo: https://github.com/davidfowl/aspire-js-chaos
- Existing docs page to update/replace: https://aspire.dev/deployment/javascript-apps/
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request