npm react router dom
snippet in javascript

npm react router dom

user3953

$ npm install --save react-router-dom

installing react router dom with yarn

user3785

npm install react-router-dom

starting with react router dom

user564

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

export default function App() {
  return (
    <Router>
      <div>
        <nav>
          <ul>
            <li>
              <Link to="/">Home</Link>
            </li>
            <li>
              <Link to="/about">About</Link>
            </li>
            <li>
              <Link to="/users">Users</Link>
            </li>
          </ul>
        </nav>

npm react router dom

user1423

// using ES6 modulesimport { BrowserRouter, Route, Link } from "react-router-dom"; // using CommonJS modulesconst BrowserRouter = require("react-router-dom").BrowserRouter;const Route = require("react-router-dom").Route;const Link = require("react-router-dom").Link;

npm react router dom

user9780

<script src="https://unpkg.com/react-router-dom/umd/react-router-dom.min.js"></script>