Oh yeah, we’re definitely using typescript for this demo □. You can do so simply by running create-react-app authguard -typescript. Let’s start by creating a new react project. We can run through this pretty quickly via create-react-app, so we’re going to do just that! If you’d like to follow along, be sure to run the commands that are formatted like create-react-app above! ![]() Namely, we show them an unauthorized screen if they’re not authorized and, if they are authorized to view that content, we show them the content. There are a couple of different ways to do this, but I’ve found a pattern that I really like that uses higher-order function components to help create the functionality that would be expected of an auth guarded route. In this case of our example today, we want to auth guard react-router routes. I’ve heard this referred to in the past as “auth guarding” specific content. A common theme in web applications is to serve specific content to authenticated users while serving other content to everyone else.
0 Comments
Leave a Reply. |