Using Redaxios, an 800-byte Axios alternative (Fetch wrapper)
Naman Gupta

Naman Gupta @insanenaman

About: <Web Ninja/>, Ex-Organiser @GDG New Delhi 👉 I do Microblogging here

Location:
India
Joined:
Mar 10, 2020

Using Redaxios, an 800-byte Axios alternative (Fetch wrapper)

Publish Date: Oct 4 '20
38 7

Hi there, Its Naman. This blog is for devs like me who use Axios frequently. I love Axios as it provides a clean API and advanced way to play around REST calls. Not only this, I even use Axios for simple GraphQL requests but sometimes I find myself just doing simple CRUD operations (GET, POST etc) using Axios which is overhead in my opinion. So, a couple of months back I found Redaxios. Its a nice little alternative and has been built by Jason Miller (creator of Preact).

Why would you use Redaxios instead of Axios

👉 Just one reason - Import Cost
I try my best to decrease the build size wherever I can. So, if you are someone like me and you are just doing basic RESTful calls then Redaxios is a great choice.

📦 Import cost according to Bundlephobia

1- Axios (Link)
Axios Import Cost

2- Redaxios (Link)
Redaxios Import Cost

🤔 How to use it?

The best thing about Redaxios is that it doesn't provide its custom API. Just use it like you use Axios.

🛠 Installation

npm i redaxios --save

🛠 Usage

import axios from 'redaxios';

(use as you would normally)

Tip: Start with Redaxios (if you are not sure) and down the line if you find that you need advanced features and Redaxios is not your cup of tea then just change the imports. That easy 😉

That's it for today. Feel free to provide any type of feedback. I do appreciate that. Meanwhile, you can find me on Twitter @InsaneNaman.

Signing off. See you soon.

Comments 7 total

  • Nida
    NidaOct 5, 2020

    Awesome! Thanks for sharing ❤️💯

  • Tuan Nguyen
    Tuan NguyenNov 19, 2020

    Can someone make a version for typescript or a package @type/redaxios ?

    • Naman Gupta
      Naman GuptaNov 19, 2020

      Is there any issue while using Redaxios with TS? Afaik, It's compatible.

      • Tuan Nguyen
        Tuan NguyenNov 20, 2020

        Here is the issue, how to fix it, I checked out the redaxios repo but can't find solution?

        alt text

        • Naman Gupta
          Naman GuptaNov 20, 2020

          Need to see the whole code. If possible please put it on gist/GitHub.

  • Sander Cokart
    Sander CokartApr 15, 2024

    Another reason is that sentry can listen for native fetch but not XMLHTTPRequests

  • suhaotian
    suhaotianMay 10, 2024

    The modern axios: xior.js

Add comment