sveltekit-negotiate · demo

Hello, world!

`sveltekit-negotiate` lets a single SvelteKit route answer with HTML, Markdown, JSON — or whatever formats you register — based on the client’s `Accept` header or a URL extension.

This page, for instance, is the same route served three ways.

Try it

The browser requested this page as text/html. Ask for a different format and you'll get the same data, serialized differently.

With curl

# as Markdown
curl -H 'Accept: text/markdown' http://localhost:5173/demo

# as JSON
curl -H 'Accept: application/json' http://localhost:5173/demo

# or via the URL extension
curl http://localhost:5173/demo.md