Loaders
Provides data to the route when rendering
- It runs on the server before rendering the page
- loaders can be create by exporting a function called loader in the route files
import type { LoaderFunction } from "@remix-run/react";
import { json } from "@remix-run/node";
export const loader: LoaderFunction = async () => {
const res = await someAsyncApiFunction();
const data = await res.json();
return json({ data });
};