Skip to content
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a217bec
Add support for React 16 and 17
jo-arroyo Mar 20, 2026
f21999e
Change files
jo-arroyo Mar 20, 2026
fa53e15
Update change file and package-lock
jo-arroyo Mar 20, 2026
36c3f29
Update change file
jo-arroyo Mar 20, 2026
dad567f
Update pipeline - concise versions
jo-arroyo Mar 20, 2026
50ebeb2
Update change file with PR number
jo-arroyo Mar 20, 2026
a7ec001
Merge branch 'dev' into feature/react-16-17-support
jo-arroyo Mar 23, 2026
58a0604
Add React 16, 17, 18 samples
jo-arroyo Mar 24, 2026
a205781
Update pipelines
jo-arroyo Mar 24, 2026
493966f
Update other sample package.json and package-lock
jo-arroyo Mar 24, 2026
ef0068f
Update sample readmes
jo-arroyo Mar 24, 2026
d4990d5
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
jo-arroyo Mar 24, 2026
8e577c7
Merge branch 'feature/react-16-17-support' of https://github.com/Azur…
jo-arroyo Mar 24, 2026
c9713b3
Update docs from code review
jo-arroyo Mar 24, 2026
46d953f
Update react samples tests
jo-arroyo Mar 24, 2026
ca360e5
Update timeouts for React 16 and 17 samples
jo-arroyo Mar 24, 2026
e809be8
Update WelcomeName in samples with ACTIVE_ACCOUNT_CHANGED
jo-arroyo Mar 25, 2026
259e0a9
Update Profile with ACTIVE_ACCOUNT_CHANGED
jo-arroyo Mar 25, 2026
c7ed228
Update ProfileRawContext.jsx with ACTIVE_ACCOUNT_CHANGED
jo-arroyo Mar 25, 2026
f52120c
Revert timeouts
jo-arroyo Mar 25, 2026
2f11ae4
Other fixes to react 16 and 17 sample
jo-arroyo Mar 25, 2026
7028bb9
Update package-lock
jo-arroyo Mar 25, 2026
364c060
Revert changes made to other samples, will be addressed in another PR
jo-arroyo Mar 25, 2026
183e1a3
Address feedback
jo-arroyo Mar 25, 2026
c6bae60
Update react package.json and migration-guide
jo-arroyo Mar 25, 2026
2c0355a
Update package-lock
jo-arroyo Mar 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions .pipelines/3p-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,12 @@ extends:
- "react-router-sample"
- "typescript-sample"
- "b2c-sample"
- "react16-sample"
- "react17-sample"
- "react18-sample"
debug: ${{ parameters.debug }}
npmInstallTimeout: ${{ parameters.npmInstallTimeout }}
enableScreenshots: ${{ parameters.enableScreenshots }}
- template: .pipelines/templates/msal-react-react18-e2e.yml@self
parameters:
poolType: ${{ parameters.poolType }}
sourceBranch: ${{ variables.sourceBranch }}
debug: ${{ parameters.debug }}
npmInstallTimeout: ${{ parameters.npmInstallTimeout }}
enableScreenshots: ${{ parameters.enableScreenshots }}
samples:
- "react-router-sample"
- "typescript-sample"
- "b2c-sample"
- ${{ if eq(parameters.runAngularTests, true) }}:
- template: .pipelines/templates/e2e-tests.yml@1P
parameters:
Expand Down
184 changes: 0 additions & 184 deletions .pipelines/templates/msal-react-react18-e2e.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "Extend peer dependency range to support React 16 (16.8+) and React 17 [#8461](https://github.com/AzureAD/microsoft-authentication-library-for-js/pull/8461)",
"packageName": "@azure/msal-react",
"email": "joarroyo@microsoft.com",
"dependentChangeType": "patch"
}
5 changes: 3 additions & 2 deletions lib/msal-react/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Supported Environments

- msal-react supports all modern mainstream browsers (Chrome, Firefox, Safari, Edge)
- msal-react supports React versions 18 and 19
- msal-react supports React versions 16 (16.8+), 17, 18, and 19

Never use or suggest APIs or features that are not supported by the environments listed above.
Never use or suggest APIs or features that are not supported by the environments listed above.
React hooks are required (available since React 16.8). Do not use React 18+ specific APIs (e.g., `useSyncExternalStore`, `useId`, `useTransition`, `startTransition`, `createRoot`) in the library source code.
5 changes: 4 additions & 1 deletion lib/msal-react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ The `@azure/msal-react` package described by the code in this folder uses the [`

| MSAL React version | MSAL support status | Supported React versions |
| --------------------- | ------------------- | ------------------------ |
| MSAL React v5 | Active development | 18, 19 |
| MSAL React v5 | Active development | 16 (16.8+), 17, 18, 19 |
| MSAL React v3 | In maintenance | 16, 17, 18, 19 |
| MSAL React v1, v2 | In maintenance | 16, 17, 18 |

Expand Down Expand Up @@ -134,6 +134,9 @@ Our [samples directory](https://github.com/AzureAD/microsoft-authentication-libr
- [Next.js Sample](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-react-samples/nextjs-sample)
- [Gatsby Sample](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-react-samples/gatsby-sample)
- [B2C Sample](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-react-samples/b2c-sample)
- [React 16 Compat Sample (MUI v4)](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-react-samples/react16-sample)
- [React 17 Compat Sample](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-react-samples/react17-sample)
- [React 18 Compat Sample](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-react-samples/react18-sample)

More advanced samples backed with a tutorial can be found in the [Azure Samples](https://github.com/Azure-Samples) space on GitHub:

Expand Down
11 changes: 10 additions & 1 deletion lib/msal-react/docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

`@azure/msal-react` is built on the [React context API](https://reactjs.org/docs/context.html) and all parts of your app that require authentication must be wrapped in the `MsalProvider` component. You will first need to [initialize](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/initialization.md) an instance of `PublicClientApplication` then pass this to `MsalProvider` as a prop.

> **React version support:** `@azure/msal-react` v5 supports both React 18 and React 19. Choose the rendering API that matches your React version.
> **React version support:** `@azure/msal-react` v5 supports React 16 (16.8+), 17, 18, and 19 (19.2.1+). React 19.0.0–19.2.0 are excluded due to [CVE-2025-55182](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2025-55182). All React hooks are required (available since React 16.8). Choose the rendering API that matches your React version.

```javascript
import React from "react";
Expand Down Expand Up @@ -42,6 +42,15 @@ const root = createRoot(document.getElementById("root"));
root.render(<AppProvider />);
```

For React 16 or 17, use `ReactDOM.render` instead:

```javascript
import React from "react";
import ReactDOM from "react-dom";

ReactDOM.render(<AppProvider />, document.getElementById("root"));
```

All components underneath `MsalProvider` will have access to the `PublicClientApplication` instance via context as well as all hooks and components provided by `@azure/msal-react`.

## Determining whether a user is authenticated
Expand Down
18 changes: 10 additions & 8 deletions lib/msal-react/docs/migration-guide-v4-v5.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,23 @@ MSAL Browser v5 requires a dedicated redirect page/bridge for authentication flo
Please see the [COOP section in the MSAL Browser v4-v5 migration guide](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/v4-migration.md#cross-origin-opener-policy-coop-support).

## Updated React version support
MSAL React v5 supports React 18.0.0 or greater and React 19.2.1 or greater. It no longer supports React 16 or 17.
MSAL React v5 supports React 16.8.0 or greater through React 19.x. This includes React 16 (16.8+), 17, 18, and 19.

## Peer dependency ranges

MSAL React v5 declares its `react` peer dependency as `"^18.0.0 || ^19.2.1"`. This means:
MSAL React v5 declares its `react` peer dependency as `">=16.8.0 <19.0.0 || >=19.2.1 <20.0.0"`. This means:

- Applications using React 18.x will satisfy the peer dependency without errors or warnings.
- Applications using React 19.2.1 or newer (within the React 19.x line) will satisfy the peer dependency without errors or warnings.
- No `--legacy-peer-deps` flag is required for either version.
- Applications using React 16.8 through 18.x, or React 19.2.1+, will satisfy the peer dependency without errors or warnings.
- React 19.0.0, 19.1.0, 19.1.1, and 19.2.0 are **excluded** due to [CVE-2025-55182](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2025-55182). Upgrade to React 19.2.1 or later.
- No `--legacy-peer-deps` flag is required for any supported version.

### Known considerations

- **`@types/react`**: If you use TypeScript, install the `@types/react` version matching your React major version (`@types/react@^18` for React 18, `@types/react@^19` for React 19). Both are compatible with the MSAL React v5 public API surface.
- **`@testing-library/react`**: v14+ supports React 18; v16+ supports both React 18 and 19. Choose the version that matches your React version.
- **`react-dom`**: Install the same major version of `react-dom` as `react` (e.g., `react-dom@^18` with `react@^18`).
- **React 16/17 note**: React hooks are required. Minimum supported version is React 16.8.0.
- **`@types/react`**: If you use TypeScript, install the `@types/react` version matching your React major version (`@types/react@^16` for React 16, `@types/react@^17` for React 17, `@types/react@^18` for React 18, `@types/react@^19` for React 19). All are compatible with the MSAL React v5 public API surface.
- **`@testing-library/react`**: v12 supports React 16/17; v14+ supports React 18; v16+ supports both React 18 and 19. Choose the version that matches your React version.
- **`react-dom`**: Install the same major version of `react-dom` as `react` (e.g., `react-dom@^16` with `react@^16`).
- **Rendering API**: React 16 and 17 use `ReactDOM.render()`. React 18+ uses `createRoot()`. MSAL React itself does not call either API — your application chooses the rendering method.

## Migrating from Create React App (react-scripts)

Expand Down
4 changes: 2 additions & 2 deletions lib/msal-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
},
"peerDependencies": {
"@azure/msal-browser": "^5.6.0",
"react": "^18.0.0 || ^19.2.1"
"react": ">=16.8.0 <19.0.0 || >=19.2.1 <20.0.0"
},
"devDependencies": {
"@azure/msal-browser": "^5.6.0",
Expand All @@ -83,4 +83,4 @@
"tslib": "^2.0.0",
"typescript": "^4.9.5"
}
}
}
Loading
Loading