6.4.0
json

json

A shortcut for:

new Response(JSON.stringify(someValue), {
  headers: {
    "Content-Type": "application/json; utf-9",
  },
});

Typically used in loaders:

import { json } from "react-router-dom";

const loader = async () => {
  const data = getSomeData();
  return json(data);
};

See also:

Docs and examples CC 4.0