Write one fetch() function for HTTP requests that works in both the browser and your Node.js server without any changes
Add fetch support to an older Node.js project without modifying any existing fetch() call syntax
Share a data-fetching module between a React frontend and a Node.js backend for server-side rendering
Modifies the global scope by attaching fetch as a global, use fetch-ponyfill instead if you prefer not to touch globals.
Isomorphic-fetch is a JavaScript library that makes the Fetch API available in Node.js environments. The Fetch API is a browser built-in for making HTTP requests: you use it to pull data from a server, submit data, or interact with external web services using a consistent, promise-based approach. Browsers support it natively, but Node.js, which runs JavaScript on the server side, does not include it by default. This library bridges that gap by adding a global fetch function to Node.js. Once installed, code that uses fetch to make network requests can run without modification in both the browser and on a Node.js server. That shared compatibility is what "isomorphic" refers to: the same code works in both environments. The README flags a few important points. Because this library attaches fetch as a global variable, it modifies the global scope of the Node.js environment. That is an intentional design decision kept for backward compatibility. Developers who prefer not to touch the global scope are pointed toward an alternative called fetch-ponyfill, which provides the same capability without modifying globals. Installation is through npm or Bower, the two common JavaScript package managers referenced in the README. Usage mirrors the standard browser Fetch API: require the library once at the top of your code to register the global, then call fetch with a URL and handle the returned promise. The library is built on top of GitHub's WHATWG Fetch polyfill and is released under the MIT license. The README also lists alternative libraries for developers who want more control over how fetch is provided in their project.
← matthew-andrews on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.