Viewing docs for an older release. View latest

This contains utilities and polyfills for Node.js.

Most of the time you will never be importing from this package directly as it's used internally by adapters such as @remix-run/express.

Polyfills

Since Remix relies on browser API's such as fetch that are not natively available in Node.js you may find that your unit tests fail without these globals when running with tools such as Jest.

Your testing framework should provide you with a hook or location to polyfill globals / mock out API's; here you can add the following lines to install the globals that Remix relies on:

import { installGlobals } from "@remix-run/node"; // or "@remix-run/cloudflare"

// This installs globals such as "fetch", "Response", "Request" and "Headers".
installGlobals();
Keep in mind that we install these for you automatically in your actual app, so you should only need to do this in your test environment.
Docs and examples licensed under MIT