Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between how react-router works and how href tag works?

What is the difference between how react-router works and just tag works?

I know there is a way I can use href tag in react but I saw most of the times people use react-router instead.

And I also found that in next.js which is a framework of react.js, href is frequently used.

Is this something to do with client-side-rendering and server-side-rendering?

like image 660
GoonGamja Avatar asked Jan 23 '26 12:01

GoonGamja


1 Answers

What is the difference between how react-router works and just tag works?

React router loads your component without reloading the page ,it just manipulates the DOM.

Is this something to do with client-side-rendering and server-side-rendering?

Yes,when your page refreshes ,most of the time you are getting something from server.

An example demo-https://codesandbox.io/s/react-router-basic-4753w?fontsize=14

You will see the last href refreshes the page ,rest others Donot ,they just change the DOM

like image 111
Shubh Avatar answered Jan 26 '26 02:01

Shubh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!