Skip to content

Instantly share code, notes, and snippets.

@LauraKokkarinen
Created May 12, 2024 09:27
Show Gist options
  • Save LauraKokkarinen/000e3f2e9b733728d3e3798a2874d136 to your computer and use it in GitHub Desktop.
Save LauraKokkarinen/000e3f2e9b733728d3e3798a2874d136 to your computer and use it in GitHub Desktop.
import { BrowserRouter } from "react-router-dom";
import { MsalAuthenticationTemplate, MsalProvider } from "@azure/msal-react";
import { PublicClientApplication, InteractionType } from '@azure/msal-browser';
import { loginRequest } from "./msalConfig";
interface AppProps {
instance: PublicClientApplication;
}
const authRequest = {
...loginRequest
};
/**
* All parts of the application that require authentication must be wrapped in the MsalProvider component.
* The MsalAuthenticationTemplate component will render its children if a user is authenticated or attempt to sign a user in.
*/
const App = ({ instance }: AppProps) => {
return (
<BrowserRouter>
<MsalProvider instance={instance}>
<MsalAuthenticationTemplate interactionType={InteractionType.Redirect} authenticationRequest={authRequest}>
{/* Content that is visible only to authenticated users */}
</MsalAuthenticationTemplate>
</MsalProvider>
</BrowserRouter>
);
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment