msal-react-lite
A lightweight Higher Order Component to quickly add MSAL to any React Project
Install
npm install --save msal-react-lite
Usage
Add the appropriate environment variables:
- REACT_APP_AAD_APP_CLIENTID
- REACT_APP_AAD_DIRECTORY_TENANTID
- REACT_APP_AAD_REDIRECT_URI
- REACT_APP_AAD_SCOPES
(e.g you could use .env)
REACT_APP_FUNCTION_ENDPOINT=http://localhost:7071REACT_APP_AAD_APP_CLIENTID=REACT_APP_AAD_DIRECTORY_TENANTID=REACT_APP_AAD_REDIRECT_URI=http://localhost:5000REACT_APP_AAD_SCOPES=/<<scope>>
Create a file for your MSAL Configuration:
(the following is a sample to help you get started you'll need to customize to your needs)
\src\config\msal-config.tsx
;;
msal-react-lite uses standard MSAL coniguration options, refer to the doucmention links below for help on configuring to meet your specific needs.
- msalConfig: See Microsoft's Documentation
- silentRequestConfig: See Microsoft's Documentation
- endSessionRequestConfig: See Microsoft's Documentation
- loginRequestConfig (loginPopup only):See Microsoft's Documentation
- redirectRequestConfig (loginRedirect only):See Microsoft's Documentation
\src\index.tsx
Add Imports
/* .. other import statements .. */
Wrap the App
component with the MsalProvider
component
\src\App.tsx
/* .. add the import .. */
License
MIT © ecfmg
Thanks
- Thanks to Travis Fischer for create-react-library which made the process of creating an NPM package quite painless.