React ~ Router ~ Introduction - rohit120582sharma/Documentation GitHub Wiki

A Single-page application (SPA) might have multiple views (aka pages), and unlike the conventional multi-page apps, navigating through these views shouldn’t result in the entire page being reloaded.

React is a popular library for building SPAs. However, as React focuses only on building user interfaces, it doesn’t have a built-in solution for routing.


React Router

React Router is the most popular routing library for React. It’s a third-party library that’s widely popular for its design and simplicity. It is a tool that allows you to handle routes.

It comprises three packages: react-router, react-router-dom, and react-router-native.

react-router is the core package for the router, whereas the other two are environment specific. You should use react-router-dom if you’re building a website, and react-router-native if you’re on a mobile app development environment using React Native.

$ npm install --save react-router-dom

A router allows your application to navigate between different components, changing the browser URL, modifying the browser history, and keeping the UI state in sync.

When you’re dealing with “Static Routing” you declare your routes as part of your app’s initialisation before any rendering takes place. “Dynamic Routing” means that routing takes place as your app is rendering, not in a configuration or convention outside of a running app. That means almost everything is a component in React Router.


References

⚠️ **GitHub.com Fallback** ⚠️