Posts

Showing posts with the label Public

Public , Private and Restricted Route using React Router

Image
In the tutorial we are going to look at, how can we make private, public and restricted route using react router. Suppose we have an app, which has a Login page, Home page and an About page. Have a look at App.js file fo the application which has simple route for mentioned pages. import React from 'react' ; import Login from './components/Login' import Dashboard from './components/Dashboard' import About from './components/About' import { BrowserRouter,Switch,Route } from 'react-router-dom' const App = () => { return ( <BrowserRouter> <Switch> <Route path= "/home" exact component={Dashboard} /> <Route path= "/login" exact component={Login} /> <Route path= "/about" component={About} /> <Route path= "/" exact component={Login} /> < /Switch> < /BrowserRouter> ); } export default ...