DEV Community

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

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

Naman Gupta
<Web Ninja/>, Co-Organizer at Google Developers Group - New Delhi, GSoC '17. Footnote - I talk Tech, love Startups, build New Products, think Creative. 😎😎
・2 min read

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.

Discussion (6)

Collapse
nidaslife23 profile image
Nida

Awesome! Thanks for sharing ❤️💯

Collapse
insanenaman profile image
Naman Gupta Author

Glad you liked it. ♥️

Collapse
nguyentuan1696 profile image
Tuan Nguyen

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

Collapse
insanenaman profile image
Naman Gupta Author

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 Author

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