`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.
sveltekit-negotiate · demo
`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.
The browser requested this page as text/html. Ask for a different format and
you'll get the same data, serialized differently.
# as Markdown
curl -H 'Accept: text/markdown' https://sveltekit-negotiate.vercel.app/demo
# as JSON
curl -H 'Accept: application/json' https://sveltekit-negotiate.vercel.app/demo
# or via the URL extension
curl https://sveltekit-negotiate.vercel.app/demo.md