Hossein Fallah
Hossein Fallah

Reputation: 2539

How to make react as fast as next.js?

I'm using react and next.js. I build the same project in both of them.

One might logically expect that next.js should be compiled slower than react.

But my next.js project gets compiled in less than 10 second, while my react project takes more than 40 seconds to compile. And it also uses a lot of CPU.

What should I do to make react as fast as next.js?

Upvotes: 1

Views: 584

Answers (2)

Ajay Raja
Ajay Raja

Reputation: 376

NextJS is always faster than React. But, You can try another way to fast up, ReactJS App with snowpack or vite. Usually React App uses webpack as Bundler. Webpack is slow in many cases.

Creating App with Snowpack is easy by,

npx create-snowpack-app my-react-app --template @snowpack/app-template-react

You can also try with Vite,

npm init vite@latest my-react-app -- --template react

Links for Reference

Snowpack

Vite

Upvotes: 2

Lasha Markhvaidze
Lasha Markhvaidze

Reputation: 65

There are some simple tricks:

  • Avoid Anonymous Functions
  • Don't use inline styles
  • Avoid Object Literals
  • Using Hooks are better
  • React.Fragments
  • Avoid using Index as Key for map
  • Avoiding Props in Initial States

these are simple tricks, I think there's no way to make react next

Upvotes: 1

Related Questions