DEV Community

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

Posted on

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

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.

Top comments (6)

Collapse
 
nguyentuan1696 profile image
Tuan Nguyen

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

Collapse
 
insanenaman profile image
Naman Gupta

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

Collapse
 
nguyentuan1696 profile image
Tuan Nguyen • Edited

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

alt text

Thread Thread
 
insanenaman profile image
Naman Gupta

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

Collapse
 
nidaslife23 profile image
Nida

Awesome! Thanks for sharing ❤️💯

Collapse
 
sandercokart profile image
Sander Cokart

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