Remix's EntryContext
The headers object to append the preload links to
export default function handleRequest(
request: Request,
statusCode: number,
headers: Headers,
context: EntryContext
) {
let markup = renderToString(
<RemixServer context={context} url={request.url} />
);
headers.set("Content-Type", "text/html");
preloadModuleAssets(context, headers); // add this line
return new Response("<!DOCTYPE html>" + markup, {
status: statusCode,
headers: headers,
});
}
Add Link headers to preload the JS modules in the route matching the current request.