Remix uses the loader function to provide a behind the scenes API for the browser side script to supply data in JSON format. The function should return serialized data using the json
instruction. When you get the error message:
ReferenceError: json is not defined
Add this line to the top of the script
import { json } from "@remix-run/node";