Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

217
Views
react nested routes default path blank page

How can I make the parent path render a default outlet in react router v6 nested routes? As you can see in the example I want to make "/dashboard" path take me to "/dashboard/home" by default.

For now it's just rendering a blank screen in the Outlet.

<Route path={"dashboard"} element={<Dashboard />}>
  <Route path={"home"} element={<Home />} />        
  <Route path={"users"} element={<Users />} />        
</Route>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can render an Index route to render some content when the path equals that of the parent route.

Example:

<Route path="dashboard" element={<Dashboard />}> // "/dashboard/*"
  <Route index element={/* some content */} />   // "/dashboard"
  <Route path="home" element={<Home />} />       // "/dashboard/home"
  <Route path="users" element={<Users />} />     // "/dashboard/users"
</Route>

If you want a specific nested route to be a "default" then either render it again as the index route or render a redirect to it.

Examples:

<Route path="dashboard" element={<Dashboard />}>
  <Route index element={<Home />} />
  <Route path="home" element={<Home />} />
  <Route path="users" element={<Users />} />
</Route>

or

<Route path="dashboard" element={<Dashboard />}>
  <Route index element={<Navigate to="home" replace />} />
  <Route path="home" element={<Home />} />
  <Route path="users" element={<Users />} />
</Route>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!