Somjit
Somjit

Reputation: 2772

What is the difference between `isomorphic-fetch` and `isomorphic-unfetch` npm packages

I see both are used for SSR. So what's the difference? Apart from isomorphic-fetch being older and slightly larger gzipped package.

Links:

Isomorphic Unfetch

Isomorphic Fetch

Upvotes: 19

Views: 11564

Answers (1)

Hossein Moradi
Hossein Moradi

Reputation: 598

The isomorphic-fetch is built on top of whatwg-fetch and isomorphic-unfetch is built on top of unfetch. What both of them are doing is switching between node-fetch and the other package for client and server.

So their difference is only in the client and the question reduces to: What's the difference between whatwg-fetch and unfetch?

The whatwg-fetch package is an almost complete polyfill for fetch API, but the unfetch is built with "bundle size" as the first priority in mind (like the other packages written by Jason Miller such as preact). The unfetch only supports a subset of the full fetch API. However, it's great if you just need simple requests in your application.

A good strategy for new applications is to use unfetch at first, and replace it with whatwg-fetch if you need any feature (such as streaming) which is not supported in unfetch.

Upvotes: 21

Related Questions