DEV Community

Cover image for 7 Essential React Libraries for Front-End Web Development

7 Essential React Libraries for Front-End Web Development

Suraj Vishwakarma on February 23, 2023

Introduction There is no doubt that React is the most popular frontend framework. New web applications are made using React or its frame...
Collapse
 
kashanahmad profile image
Kashan Ahmad • Edited

And how are these libraries essential? What's the basis? Not to mention that Redux is outdated and suggests Redux/Toolkit by itself.

Collapse
 
leob profile image
leob

Yep if you need Redux then what you really want is Redux Toolkit, unless you really love writing boiler plate!

Collapse
 
surajondev profile image
Suraj Vishwakarma

As this provide more functionality such as routing, testing and components building.

Collapse
 
joelbonetr profile image
JoelBonetR πŸ₯‡

What you want is called Next JS sir 😁

Thread Thread
 
surajondev profile image
Suraj Vishwakarma

Definetly a good choice instead of CRA but still you will need libraries to make it evern more powerful.

Thread Thread
 
joelbonetr profile image
JoelBonetR πŸ₯‡ • Edited

You don't need a "powerful" environment. You need an environment that can cover your needs while being dynamic enough so you can add building blocks into it whenever necessary.

With something like that you're good to go for a full E2E project as starter:

dependencies: {
  next,
  styled-components (or any other of your preference),
  sequelize (+ the DB driver you use),
  joi (or any other schema validator of your preference)
}
devDependencies: {
  typescript,
  prettier,
  eslint,
  eslint-config-next,
  ts-jest,
  sequelize-cli,
  testing-library/react,
  "@types/whatever"
}
Enter fullscreen mode Exit fullscreen mode


*Swap sequelize by Mongoose if you use Mongo DB.

Thread Thread
 
kuvambhardwaj profile image
Kuvam Bhardwaj

I go with Prisma when starting any new projects instead of sequelize, Have you heard about it?

Has a pretty developer experience imo

Thread Thread
 
joelbonetr profile image
JoelBonetR πŸ₯‡ • Edited

I've sure heard of it!

I've recently checked the details on both Prisma and TypeORM and I decided to go for Prisma on my next side-project to test it on my own 😁

Did you use Sequelize before? Or Mongoose?

I saw that Prisma can handle both SQL and Mongo (among others) but i don't really know the pros and cons of using it vs Sequelize/Mongoose yet (tech details, performance...).

Any advice/tip that you can provide would be much appreciated πŸ˜€

Thread Thread
 
kuvambhardwaj profile image
Kuvam Bhardwaj

For some reason I didn't like the Developer Experience with Sequelize or even Mongoose so I prefer Prisma for everything,

I love their simple language they use in the schema file, makes it really simple to define relationships.

I dont know much about the performance & benchmarks compared to other ORMs but I haven't ran into any such bottle necks yet, so I keep using it πŸ˜„

Thread Thread
 
joelbonetr profile image
JoelBonetR πŸ₯‡ • Edited

Well, using Sequelize you just throw the CLI command and it does everything for you, you don't need to write schemas manually πŸ˜…

e.g.

npx sequelize-cli model:generate --name User --attributes firstName:string,lastName:string,email:string
Enter fullscreen mode Exit fullscreen mode

Can't you do that with Prisma? 😱

Thread Thread
 
kuvambhardwaj profile image
Kuvam Bhardwaj

No, you can't do that in Prisma, seems interesting though

Thread Thread
 
joelbonetr profile image
JoelBonetR πŸ₯‡

πŸ₯² disappointing, I've been interacting with ORMs this way for 10 years in different languages/platforms...

Collapse
 
stianhave profile image
Stian HΓ₯ve

In my opninion toolkit is king compared to Redux, however i prefer zustand over all of the above.

Collapse
 
thethirdrace profile image
TheThirdRace

I think these are all great librairies. They all solved something that we needed with React.

I personally used all of them, but the only ones I'd only ChakraUI and React Testing Library nowadays. And I'm only including ChakraUI because of their roadmap for V3. If it doesn't fulfil their promises, I'll most likely remove it from my toolbelt.

The huge problem with all these librairies is that once you install them all, you already bust the recommended JS bundle size of 130 to 170 KB. Just for a "hello world" page...

React Router is nice, but the migrations over the years are making it a very risky move. I prefer using NextJS, but if I had to use a router, I'd probably go with the one from Tanner Linsley (aka the Tan stack).

I still haven't found a good use for Redux or Redux Toolkit. React Query will definitely do better with a smaller JS footprint. The problem with Redux is that it's a very big for the small amount of global state you should use. Server state, local state and url state should cover pretty much all your needs, what's left is very few outliers and you're definitely paying a huge price if you're going for Redux in these cases...

Chakra is awesome, I love it. But I also hate the 100 KB of gzip JS just so you get a button displayed on the screen. The V3 roadmap could really help lower the bundle size, but until then I'd look at ZagJS which was created by ChakraUI creators to tackle the JS bundle size problem among other problems.

Axios is perfectly fine, but I usually don't have 11KB to burn on my JS bundle size. Especially now that fetch is supported in all browsers, NodeJS and Cloudflare workers...

React Helmet is a must if you're not using a framework that manages it for you. Fortunately, I use NextJS so I never had to use it.

React Testing Library is awesome. I have absolutely nothing negative to say about it.

Framer-Motion is a great animation library. Unfortunately, it's a pile of poo when looking at the JS bundle size and it's not tree-shakeable (technically it is, but you'll tree-shake 5KB at most, which is a drop in the ocean at this point). It's almost as costly as the whole React-Dom package, it makes no sense whatsoever to use it. Especially since most animations could be done with 2 CSS classes and less than 5 lines of JS.

Again, all these libraries are great. They work well and are usually a blast to develop with. The only problem is the cost the clients need to pay is simply too big to be performant. There's a reason the new generation of JS frameworks are all looking into reducing their bundle size as much as possible...

Collapse
 
leob profile image
leob

Great reality check :)

Collapse
 
banonotit profile image
BANO.notIT

Where chakra ui roadmap is located? Can you give a link?

Collapse
 
thethirdrace profile image
TheThirdRace

Here you go: Chakra UI V3 roadmap

Collapse
 
joelbonetr profile image
JoelBonetR πŸ₯‡

Completely agree.
If you think it in depth, developments that put 15-20 libs to begin with are not so different than picking a Wordpress and just push plug-ins into it and in this situation probably the second's way faster to GTD πŸ˜…

Collapse
 
prems5 profile image
PREM KUMAR

someone coming up with what is react , angular post after seeing this

Collapse
 
tomeq34 profile image
Tomeq34

I miss CoreUI React Library like here: coreui.io/react/

Collapse
 
ebuka1anthony profile image
ebuka anthony

Nice Article Suraj, Newbies like us will definitely get value from this

Collapse
 
surajondev profile image
Suraj Vishwakarma

Glad that you like it!

Collapse
 
surajondev profile image
Suraj Vishwakarma

What you install with React when setting up project?

Collapse
 
joelbonetr profile image
JoelBonetR πŸ₯‡ • Edited

I install zero dependencies (aside from react, react-dom and testing libs) and just add things when I really need them.

Adding libs for simple tasks that can be accomplished easily without them is a very bad practice that pays off later on.
You'll need to handle the versions of each one and solve compatibility issues and it's definitely better to do so with 4 dependencies than doing it when you've like 20.

Collapse
 
surajondev profile image
Suraj Vishwakarma

Yes, that a good thing. Having low library will definetly improve performance.

Thread Thread
 
joelbonetr profile image
JoelBonetR πŸ₯‡

I don't even use CRA whenever I need to use React.

npm i -D parcel-bundler
npm i react react-dom

Create an index.js file in your root directory like that:

import React from "react"
import ReactDOM from "react-dom"

ReactDOM.render(<h1>Hello world!</h1>, document.getElementById("root"))
Enter fullscreen mode Exit fullscreen mode

Create an index.html file in your root directory:
index.html

Add this inside the <body> tag:

<body>
    <div id="root"></div>
    <script src="./index.js"></script>
</body>
Enter fullscreen mode Exit fullscreen mode

add the start command in your package.json:
"start": "parcel index.html --open"

and you're good to go 😁

Collapse
 
lukeecart profile image
Luke Cartwright

Thank you for sharing these,
The link to the react testing library is showing a 404. Please could you update the link

Collapse
 
surajondev profile image
Suraj Vishwakarma

It has been fixed. Thanks for repoting it.

Collapse
 
johnatandias profile image
Johnatan Dias

It's worth putting MSW on this list.

Collapse
 
joelbonetr profile image
JoelBonetR πŸ₯‡

I don't even know what MSW is, that's what google point me where searching for it:
magicseaweed.com/ and now I'm more confused than before πŸ˜…

Collapse
 
andrewwebcoder profile image
Andrew-web-coder

Well, for me Fancyapps UI components are also essential, but it definitely depends on the project.