# Content Negotiation

Serve the same route as HTML, Markdown or JSON, depending on what the client asks for. Useful for making pages readable by agents and scripts without building a parallel API.

### Syntax

```
$ vela enable content-negotiation
```

This wires up [`sveltekit-negotiate`](https://github.com/nathancahill/sveltekit-negotiate) in `hooks.server.ts`, adds a `reroute` hook and drops a `<Negotiate />` component into the root layout. A request for `text/markdown` or `application/json` then gets that representation of the page instead of HTML.

Has no dependencies — it works with or without a backend, and composes with [i18n](/enable/i18n)'s own reroute hook.

It also adds a demo page at `/negotiate`, in the project's `(public)` group, or directly under `src/routes` in a project that has no such group. Its `+page.ts`, which sets the page's meta tags, is only written when the project has `svelte-meta-tags`.

A project without a `src/hooks.server.ts` gets one. If it has a `hooks.server.js` instead, that file is left alone and the lines to add are printed.

### Reverting

[`vela disable content-negotiation`](/disable/content-negotiation) removes the wiring and the generated files.