MENU

Fun & Interesting

React Protected Routes | Role-Based Authorization | React Router v6

Dave Gray 409,074 3 years ago
Video Not Working? Fix It Now

Web Dev Roadmap for Beginners (Free!): https://bit.ly/DaveGrayWebDevRoadmap React Protected Routes allows you to make part of your React app exclusive to authorized users. Role-Based Authorization allows different levels of access based upon the assigned user roles. This tutorial utilizes React Router v6. 💖 Support me on Patreon ➜ https://patreon.com/davegray ⭐ Become a full-stack web dev with Zero To Mastery Courses: - Advanced React & Redux: https://bit.ly/AdvReactDev - Jr to Senior Web Dev Roadmap: https://bit.ly/WebDevRoadmap-JrtoSr - Master FAANG Coding Interviews: https://bit.ly/FAANGInterview 🚩 Subscribe ➜ https://bit.ly/3nGHmNn 🚀 React JS for Beginners full course - 9 hours: https://youtu.be/RVFAyFWO4go 🔗 Source Code: https://github.com/gitdagray/react_protected_routes 📬 Course Updates ➜ https://courses.davegray.codes/ React Protected Routes | Role-Based Authorization | React Router v6 (00:00) Intro (00:53) Welcome and Startup (01:27) Install React Router v6 (02:17) Update index.js with RRv6 (03:38) Basic Routing Setup (07:41) useAuth hook (10:06) RequireAuth component v1 (14:38) Manage browser history (18:50) Testing with backend authentication (21:00) RequireAuth component v2 (24:26) Applying Role-Based Routing (26:35) Object lookup for roles (28:15) Testing role-based routes (29:37) Last note on the Unauthorized component ☕ Buy Me A Coffee: https://www.buymeacoffee.com/davegray 🔗 React Router Version 6 in 20 minutes: https://youtu.be/XBRLVRjZ3CQ 🔗 React User Login and Authentication with Axios: https://youtu.be/X3qyxo_UTR4 🔗 React Register Form with Validation, Axios and a11y: https://youtu.be/brcHK3P6ChQ 🔗 Node JS Full Course (with source code) for building the backend REST API that will receive your form submissions: https://youtu.be/f2EqECiTBL8 🔗 FontAwesome for React: https://fontawesome.com/v5.15/how-to-use/on-the-web/using-with/react 🔗 RegExr for Regular Expressions: https://regexr.com/ 📚 Accessible Form References: WebAIM.org - Advanced Forms: https://webaim.org/techniques/forms/advanced WebAIM.org - Form Validation: https://webaim.org/techniques/formvalidation/ MDN - Aria Attributes: aria-invalid: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-invalid_attribute aria-describedby: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-describedby aria-live: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-live aria-label: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-label 🔗 ES7 React JS Snippets Extension for VS Code: https://marketplace.visualstudio.com/items?itemName=dsznajder.es7-react-js-snippets 🔗 React Dev Tools Extension for Chrome: https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi 📚 References: ReactJS Official site: https://reactjs.org/ React Wikipedia: https://en.wikipedia.org/wiki/React_(JavaScript_library) React Jobs: https://www.ziprecruiter.com/candidate/search?search=react&location= ✅ Follow Me: Github: https://github.com/gitdagray Twitter: https://twitter.com/yesdavidgray LinkedIn: https://www.linkedin.com/in/davidagray/ Blog: https://yesdavidgray.com Reddit: https://www.reddit.com/user/DaveOnEleven Was this tutorial about creating protected routes and role-based user authorization in React with React Router v6 helpful? If so, please share. Let me know your thoughts in the comments. #react #protected #routes

Comment