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");
preloadRouteAssets(context, headers); // add this line
return new Response("<!DOCTYPE html>" + markup, {
status: statusCode,
headers: headers,
});
}
Combine
preloadLinkedAssets
andpreloadModuleAssets
into a single function and preload both linked and module assets.