How to redirect / path into /app in react router 6?

442 Views Asked by At

I have different routes for different pages.

<Routes>
<Route path="/"/>
<Route path='/app' element={home}/>
</Routes>

How to redirect / into /app in the new version of react router?

1

There are 1 best solutions below

0
On

you can do as shown below

<Routes>
  <Route exact path="/app" element={<home />} />
  <Route path="*" element={<Navigate to="/" />} />
</Routes>