# Netlify Edge Functions

`netlify.edge: true`, or `--preset netlify-edge`, builds the server for the `browser` target as a Netlify Edge Function: `.netlify/v1/edge-functions/server.mjs` is the whole bundle followed by the `config` export Netlify reads from the source, `{ path: "/*", excludedPath: [...] }`. No `manifest.json` is written. `excludedPath` lists the files of `public/` and of the build, because an Edge Function runs before static files and before `_redirects`: a page file such as `/about/index.html` is listed as `/about/index.html`, `/about/` and `/about`. Past 100 entries the list is collapsed by directory (`/img/*`), but never over a path the app answers, so the endpoints under `/_hamur/` (server functions, islands, tasks, `revalidate`, …) stay with the function; when a file cannot be listed the build warns and the function answers it. `dist/` holds the public files, `_headers` and `_redirects`, as for `netlify`. The bundle imports no `node:` module, so `fs`, `sqlite` and `redis` storage fail the build, and `scheduledTasks`, `tasks.runOnStart`, WebSockets and `build.serverBundles` are refused. `context.waitUntil` and `context.ip` are Netlify's and the runtime config reads `Netlify.env`. The `netlify-smoke` workflow deploys an edge fixture as a second draft to the same site.

## Reference

|                      |                        |
| -------------------- | ---------------------- |
| Preset               | `netlify-edge`         |
| Runs on              | Netlify Edge Functions |
| `event.runtime.name` | `netlify-edge`         |
| Server target        | `browser`              |
| Lifetime, startup    | `request`, `request`   |

### Output

```text
.netlify/v1/edge-functions/
  server.mjs                 the whole bundle, then the `config` export Netlify reads
dist/                        public files, _headers and _redirects
```

### Config keys

| Key            | Default | What it does                                                     |
| -------------- | ------- | ---------------------------------------------------------------- |
| `netlify.edge` | `false` | `true` builds this preset; `--preset netlify-edge` does the same |

### Detection

None. Set `netlify.edge: true` or name it with `--preset netlify-edge`; the `netlify` preset is chosen when `NETLIFY` is set.

### Deploy command

`hamur deploy` builds, then runs `netlify deploy --no-build --dir dist --prod`; with `--preview` it runs `netlify deploy --no-build --dir dist`. See [`hamur deploy`](/deploy/platforms/hamur-deploy). The preview command of the preset, which `hamur preview` runs or prints, is `netlify dev --dir dist`.

### Limits

- Runs: streamed answers.
- Experimental: private `app/env.ts` entries read at run time.
- Does not run: WebSockets and `server.syncedState`, `server.pubsub`, `server.metrics`, image transforms at run time, Durable Object classes.
- Platform image service: `netlify` (what `provider: "auto"` picks).
- `fs`, `sqlite` and `redis` storage fail the build; `scheduledTasks`, `tasks.runOnStart`, WebSockets and `build.serverBundles` are refused.

The levels are the `features` of the preset: `hamur build` warns or fails when the app uses a feature the preset does not run (see [Preset features](/deploy#preset-features)).
