Coding⏱️ 2 min read📅 2026-06-03

How to Fix: Error: [PrivateRoute] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>

Error in React Router v6 private route component.

Quick Answer: The issue is caused by the Navigate component being used directly as a child of Route. Instead, use a Fragment or wrap the Navigate component with a Route.

To resolve the error "Error: [PrivateRoute] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>", you need to wrap your PrivateRoute with a Route component.

🛠️ Step-by-Step Verified Fixes

Method 1: Wrap PrivateRoute with Route component

  1. Step 1: Import the Route component from react-router-dom.

Method 1: Wrap PrivateRoute with Route component (continued)

  1. Step 2: Wrap your PrivateRoute component with the Route component.

Here is an example of how you can do it:

import React from 'react';
import { Route, Navigate } from 'react-router-dom';
import { isAuth } from 'auth';

function PrivateRoute({ element, path }) {
const authed = isAuth();
const ele = authed === true ? element :

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions