# React Router 7: Private Routes (alias Protected Routes)

DevFeed: [React Router 7: Private Routes (alias Protected Routes)](<https://devfeed.tech/articles/react-router-7-private-routes-alias-protected-routes-18971.md>)

Original publisher: [Read original article](<https://www.robinwieruch.de/react-router-private-routes/>)

Author: Robin Wieruch

Published: 2025-01-06T05:52:47Z

Content type: tutorial

Language: en

Sources: [Robin Wieruch](<https://devfeed.tech/sources/robin-wieruch.md>)

Topics: [React Router](<https://devfeed.tech/topics/react-router.md>), [React](<https://devfeed.tech/topics/react.md>)

Tags: [authentication](<https://devfeed.tech/tags/authentication.md>), [authorization](<https://devfeed.tech/tags/authorization.md>), [fallback](<https://devfeed.tech/tags/fallback.md>), [jsx](<https://devfeed.tech/tags/jsx.md>), [login](<https://devfeed.tech/tags/login.md>), [logout-button](<https://devfeed.tech/tags/logout-button.md>), [permissions](<https://devfeed.tech/tags/permissions.md>), [private](<https://devfeed.tech/tags/private.md>), [react](<https://devfeed.tech/tags/react.md>), [react-component](<https://devfeed.tech/tags/react-component.md>), [react-router](<https://devfeed.tech/tags/react-router.md>), [react-router-7](<https://devfeed.tech/tags/react-router-7.md>), [react-router-private-routes](<https://devfeed.tech/tags/react-router-private-routes.md>), [react-router-protected-routes](<https://devfeed.tech/tags/react-router-protected-routes.md>), [react-router-tutorial](<https://devfeed.tech/tags/react-router-tutorial.md>), [redirect](<https://devfeed.tech/tags/redirect.md>), [roles](<https://devfeed.tech/tags/roles.md>), [route](<https://devfeed.tech/tags/route.md>), [tutorial](<https://devfeed.tech/tags/tutorial.md>)

## AI overview

Private routes in React Router 7 restrict pages to users who meet their authorization requirements, which can include authentication, roles, or permissions. The excerpt demonstrates simulating login state with React's useState, then checking that state in a page component: unauthenticated users are redirected to the Landing page with React Router's Navigate component, while authenticated users see the page. It also notes that logging out while on a protected page triggers a redirect. The tutorial exempts the public Landing route and says Home and Dashboard share requirements, while other pages may differ. The excerpt warns that placing these checks in individual components does not scale; it ends before showing the alternative.

## Source excerpt

How to use Private Routes in React Router 7 (alias Protected Routes) by using conditions (e.g. authentication, permissions, roles) to authorize users for guarded pages ...