---
title: Static assets
description: "Serve files from the edge, with your handler owning only the paths it wants."
---

## Configuration

```jsonc
"assets": {
  "directory": "public",
  "binding": "ASSETS",
  "not_found_handling": "single-page-application",
  "run_sprout_first": ["/api/*"]
}
```

## How requests are routed

The edge serves matching files directly. Your handler only calls `env.ASSETS.fetch(request)` for paths it wants to own (an SPA shell, an auth gate). This call returns text assets only — the edge handles binary files.

```js
fetch(request) {
  const url = new URL(request.url);
  if (url.pathname.startsWith("/api/")) return handleApi(request);
  return env.ASSETS.fetch(request);
}
```

## Options

| Field | Values | Behavior |
| --- | --- | --- |
| `not_found_handling` | `"none"` | A plain 404 from the edge. |
| | `"single-page-application"` | Unknown GETs serve `index.html` with a 200. |
| | `"404-page"` | Unknown paths serve `/404.html` with a real 404. |
| `run_sprout_first` | `true` | Every request goes to the handler first. |
| | `string[]` (globs) | Only matching paths go to the handler first — usually what you want, e.g. `["/api/*"]`. |

:::tip
Use `404-page` for a static site: an SPA fallback on a site with no client-side router turns every typo into a 200.
:::

## Related

- [Platform limits](/platform/limits) — asset upload caps
