---
title: "Discussion on \"How to Create Protected Routes in React with React-Router V6\" | Hashnode"
description: "Discussion on \"How to Create Protected Routes in React with React-Router V6\". Learn how to create protected routes in react using react-router version 6."
url: "https://hashnode.com/posts/how-to-create-protected-routes-in-react-with-react-router-v6/631ddb343e8d6f3497ad6465"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [How to Create Protected Routes in React with React-Router V6](https://thinkpanda.hashnode.dev/how-to-create-protected-routes-in-react-with-react-router-v6?utm_source=hashnode&utm_medium=feed)

Learn how to create protected routes in react using react-router version 6.

Sep 11, 2022 · 4 min read · thinkpanda.hashnode.dev  
Read the article

-   [#reactjs](https://hashnode.com/tag/reactjs)
-   [#programming-tips](https://hashnode.com/tag/programming-tips)
-   [#week4](https://hashnode.com/tag/week4)
-   [#4articles4weeks](https://hashnode.com/tag/4articles4weeks)
-   [#javascript](https://hashnode.com/tag/javascript)

## Written by

[ISAAC NDUBUISI](https://hashnode.com/@ThinkPanda)

@ThinkPanda · Lagos, Nigeria

  
[View profile](https://hashnode.com/@ThinkPanda)

Hey, I am technical writer and Software Engineer.

## Responses 1

Markdown supported · ⌘↵ to post

[Chukwuka Reuben](https://hashnode.com/@Reuben09)

[Sep 14, 2022](https://hashnode.com/posts/how-to-create-protected-routes-in-react-with-react-router-v6/631ddb343e8d6f3497ad6465/comment/6321ab0e07b360723689d86b)

Good day bro, let's say I do want to access the secret page, how do I have the token stored in my storage and what will the token look like

[ISAAC NDUBUISI](https://hashnode.com/@ThinkPanda)

[Sep 14, 2022](https://hashnode.com/posts/how-to-create-protected-routes-in-react-with-react-router-v6/631ddb343e8d6f3497ad6465/comment/6321ab0e07b360723689d86b#reply-6321bfa25483096daa0ab257)

Hey Friend, we usually get the JWTs stored in our localStorage through the backend. JWTs are primarily used to allow access to specific routes that are only permitted to us in exchange for authorization keys(in most cases our username and password). The JWT consists of three parts header, payload and signature which are separated by dots ( for example kyJ0eXAiOiJKV1QiLCJhbGciOiJIUiI1NiJ9. kyJ1c2VybmFtZSI6IlRoaW5rcGFuZGEifQ. og0a5SNbfJ1wj-1BkBjfpFUYz4wkORu-9K-VSHME0Rc). For our simple react application though, we can hardcode our token into our application since we are not connected to a backend by right-clicking on inspect and then going into the URL in our storage and inputting a key of string `token` and random string of characters for the `value`. We can then successfully navigate to the secret page.

I wrote more on this Setting up JWT authentication, and user Login in my How I built a budgeting Web API tutorial here: [thinkpanda.hashnode.dev/how-i-built-a-budgeting-w…](https://thinkpanda.hashnode.dev/how-i-built-a-budgeting-web-api-with-django)

note: when dealing with a backend you'd have to put in checks to make sure users don't tamper, or hardcode their token.

Thanks for reading I hope this answered your question. You can always reach out to me on @/thinkpanda404 on Twitter for a deeper guide into how it works. The comment section doesn't allow me to post pictures ;)

[Chukwuka Reuben](https://hashnode.com/@Reuben09)

[Sep 19, 2022](https://hashnode.com/posts/how-to-create-protected-routes-in-react-with-react-router-v6/631ddb343e8d6f3497ad6465/comment/6321ab0e07b360723689d86b#reply-6328ea69195e7dc741da6813)

[ISAAC NDUBUISI](https://hashnode.com/@ThinkPanda) thank you boss, will look through the article
