- npx create-react-app my-react-azureAD-app
//Navigate to the project folder
- cd my-react-azureAD-app
- npm install @azure/msal-react @azure/msal-browser
Now that we are done with Azure AD registraion of our applicaiton, lets go back to our react-app "my-react-azureAD-app".
scopes can also take below values
import logo from "./logo.svg";
import "./App.css";
import { useIsAuthenticated } from "@azure/msal-react";
import { Login } from "./Login";
function App() {
const isAuthenticated = useIsAuthenticated();
return (
<div>
{isAuthenticated ? (
<h1>Welcome to our application. You are logged in </h1>
) : (
<Login />
)}
</div>
)}
Thats how you interagrate Azure AD with react app.I hope you found this artilce helpful in setting up Azure AD authentication for your React app. If you have any questions or feedback, feel free to leave a comment below. Happy coding, and stay secure!
Link to official Microsoft Website- Enabling Authenticaion in React SPA App
Link to my blog where i show securing a .NET Core Web API with Azure AD Authentication App
Email me at "techspacedeck@gmail.com" incase you have queries. Alternatively, you can fill the "CONTACT" form or drop a comment below