How toPrevent the Remix loader to run after document request

Let's say you're building a route that needs a loader, but you only want this loader to really run once on the document request, for a client-side navigation from another route you most likely already have the loader data for any reason and want to avoid Remix to fetch the loader

You can export a clientLoader function from your route to control when the server loader runs, which can be never.

app/routes/something.ts
export async function loader(args: LoaderFunctionArgs) { // some code that probably take a lot to run } export function clientLoader() { return null }

With this simple clientLoader function, we can ensure that the server loader will run on a document request only.