공식 문서 참고 https://reactrouter.com/web/guides/quick-start

yarn add react-router-dom

1. App.js 맛보기

import React from "react";
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
import Home from "pages/Home";

function App() {
  return (
    <Router>
      <Switch>
        <Route exact path="/" component={Home} />
      </Switch>
    </Router>
  );
}

export default App;

2. 간단한 Link 활용

import React from "react";
import { BrowserRouter as Router, Switch, Route, Link } from "react-router-dom";

<Router>
  <Link to="/">Home</Link>
  <Link to="/about">About</Link>
  <Link to="/topics">Topics</Link>
  <Switch>
    <Route exact path="/" component={() => <h1> home </h1>} />
    <Route path="/about" component={() => <h1> about</h1>} />
    <Route path="/topics" component={() => <h1> topics</h1>} />
  </Switch>
</Router>