api.static() lets you serve frontend assets (React, Vite, TanStack, etc.) directly from your UpNext API. UpNext automatically builds your frontend and serves the output — no need to commit built assets to git.
Basic usage
Mount a directory of static files at a URL path:./public at /assets — for example, ./public/logo.png is served at /assets/logo.png.
Frontend builds
When you set apackage_manager, UpNext provides sensible defaults for build_command and dev_command:
Supported package managers
| Package Manager | Value | Default build | Default dev | Install command |
|---|---|---|---|---|
| Bun | PackageManager.BUN | bun run build | bun dev | bun install --frozen-lockfile |
| npm | PackageManager.NPM | npm run build | npm run dev | npm ci |
| Yarn | PackageManager.YARN | yarn build | yarn dev | yarn install --frozen-lockfile |
| pnpm | PackageManager.PNPM | pnpm build | pnpm dev | corepack enable && pnpm install --frozen-lockfile |
Running modes
Production (default)
build_command, then serves the built output via FastAPI.
Dev mode
bun dev) as subprocesses alongside the Python API, giving you HMR and hot reload. Also enables FastAPI debug mode.
Skip build (Docker / cloud)
SPA mode
By default, static mounts use SPA (Single Page Application) mode. This means any request that doesn’t match a static file returnsindex.html, enabling client-side routing.
Multiple mounts
You can mount multiple static directories on the same API:path="/" is always mounted last — you can call api.static() anywhere in your code without worrying about ordering.
Static options
| Parameter | Type | Default | Description |
|---|---|---|---|
path | str | required | URL path to mount at |
directory | str | required | Directory containing static files (or source) |
package_manager | PackageManager | None | Package manager for build/dev |
build_command | str | auto from package_manager | Command to build frontend assets |
dev_command | str | auto from package_manager | Command to start dev server |
output | str | None | Directory containing built output |
spa | bool | True | Enable SPA fallback to index.html |
When
package_manager is set, build_command and dev_command are automatically derived. Override them only if your project uses non-standard commands.Next: Context
Track progress, save checkpoints, and send structured logs.