Custom Node.js

Deploying to a Custom Node.js Runtime

This document is a work in progress. There's not much to see here (yet).

Version Support

React Router officially supports Active and MaintenanceNode LTS veleases (1) at any given point in time. Dropping support for End of Life Node versions may be done in a React Router Minor release.

Polyfilling fetch

At the time React Router v7 was released, all versions had a usable fetch implementation so there is generally no need to polyfill any fetch APIs so long as you're on Node 22 or one of the later Node 20 releases.

  • Node 22 (Active LTS) has a stable fetch implementation
  • Node 20 (Maintenance LTS) has an experimental (but suitable from our testing) fetch implementation

If you do find that you need to polyfill anything, you can do so directly from the undici package which node uses internally.

import {
  fetch as nodeFetch,
  File as NodeFile,
  FormData as NodeFormData,
  Headers as NodeHeaders,
  Request as NodeRequest,
  Response as NodeResponse,
} from "undici";

export function polyfillFetch() {
  global.File = NodeFile;
  global.Headers = NodeHeaders;
  global.Request = NodeRequest;
  global.Response = NodeResponse;
  global.fetch = nodeFetch;
  global.FormData = NodeFormData;
}

Footnotes

  1. Based on timing, React Router may drop support for a Node Maintenance LTS version shortly before it goes end-of-life if it better aligns with a React Router Major SemVer release.

Docs and examples CC 4.0