课程: React: Authentication

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Creating private React routes

Creating private React routes

- [Instructor] All right now that we've got our login and sign up pages completed the next step for our frontend, before we actually start implementing authentication functionality, is for us to add the concept of private routes to our frontend. Basically, what this means is that there are going to be certain pages in our application that we only want authenticated users to be able to see. So in our case, that's just going to be the user info page where we display the user's information. And we don't want unauthenticated users to see this, obviously, because we need to know who the user actually is before we allow them to see and modify their data on the frontend. So as with most things in react, there are several different ways that I've seen to implement private routes. But personally my favorite way is to create a separate private route component. So let's do that. Let's first create a new directory here and…

内容