# Microsoft.AspNetCore.SpaServices

**Kind:** Service

**Source:** `Pams/Web/Pams.Web/Pams.Web.csproj` (line 1)

**Part of:** [Pams](subsystem-pams)

NuGet package dependency

`Microsoft.AspNetCore.SpaServices` is a NuGet package dependency in `Pams.Web.csproj` for ASP.NET Core single-page application support. It connects the ASP.NET Core host with SPA development and request handling behavior in the web project.

## Diagram

```mermaid
sequenceDiagram
    participant Browser
    participant SpaApp as SPA client
    participant WebApp as Pams.Web
    participant SpaServices as Microsoft.AspNetCore.SpaServices

    Browser->>SpaApp: Load application
    SpaApp->>WebApp: Send API request
    WebApp->>SpaServices: Apply SPA service behavior
    WebApp-->>SpaApp: Return API response
    SpaApp-->>Browser: Render updated view
```

## Usage

```ts
async function loadPamsData() {
  const response = await fetch("/api/pams");

  if (!response.ok) {
    throw new Error("Unable to load Pams data.");
  }

  return response.json();
}

loadPamsData()
  .then((data) => {
    console.log(data);
  })
  .catch((error) => {
    console.error(error);
  });
```

## AI Coding Instructions

- Keep `Microsoft.AspNetCore.SpaServices` package configuration in `Pams.Web.csproj`.
- Route SPA API calls through ASP.NET Core endpoints rather than hard-coding external server addresses.
- Confirm SPA fallback behavior does not intercept API routes or static asset requests.
- Match client request paths, such as `/api/pams`, with routes registered by the ASP.NET Core application.

## Used by

1 reference from 1 file. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

### Injected or called by (1)

- `Pams.Web` — `Pams/Web/Pams.Web/Pams.Web.csproj`:1
