DEV Community

Jack Pritom Soren
Jack Pritom Soren

Posted on

React Router Dom V6 Boilerplate

Package:
React Router Dom

Installation
Npm: npm install react-router-dom@6
Yarn: $ yarn add react-router-dom@6

App.js

import { BrowserRouter as Router, Route, Routes } from "react-router-dom";

const App = () => {
  return (
        <Router>
              <Routes>
                <Route path="/" element={<Component_Name />} /> //home directory
                <Route path="/path_name" element={<Component_Name />} /> 
                <Route path="/path_name/:dynamic" element={<Component_Name />} /> //dynamic route
                <Route path="/path_name" element={<Component_Name />} />
                <Route path="/*" element={<Component_Name />} /> 
              </Routes>
        </Router>
  );
};

export default App;
Enter fullscreen mode Exit fullscreen mode

Follow me on : Github Linkedin

Top comments (0)