# @fluentui/react-window-provider

> Utilities for providing and consuming the window/document objects even across portal/iframe/child-window boundaries.

Latest version **2.3.2** (published 2025-12-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install @fluentui/react-window-provider
pnpm add @fluentui/react-window-provider
yarn add @fluentui/react-window-provider
bun add @fluentui/react-window-provider
```

## Health

**Score 65/100 (B)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high maintenance score; popular repo.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.3.2 |
| Published | 2025-12-10 |
| First published | 2020-08-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 89 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 20283 |
| Maintainers | chrisdholt, miroslavstastny, levithomason, uifabricteam, uifrnbot, layershifter, justslone, microsoft1es, sopranopillow |

## Links

- npm: https://www.npmjs.com/package/@fluentui/react-window-provider
- Repository: https://github.com/microsoft/fluentui
- Homepage: https://github.com/microsoft/fluentui#readme
- Issues: https://github.com/microsoft/fluentui/issues
- npm.io page: https://npm.io/package/@fluentui/react-window-provider

## Dependencies (2)

- [tslib](https://npm.io/package/tslib.md) ^2.1.0
- [@fluentui/set-version](https://npm.io/package/@fluentui/set-version.md) ^8.2.24

## Recent versions

- 2.3.2 (latest) — 2025-12-10
- 1.0.6 (lts-7) — 2022-10-31
- 2.0.0-beta.9 (beta) — 2021-02-22
- 2.3.1 — 2025-11-11
- 2.3.0 — 2025-10-23
- 2.2.30 — 2025-05-08
- 2.2.29 — 2025-02-21
- 2.2.28 — 2024-08-01
- 2.2.27 — 2024-06-24
- 2.2.26 — 2024-06-06
- 2.2.25 — 2024-05-28
- 2.2.24 — 2024-05-24
- 2.2.23 — 2024-05-23
- 2.2.22 — 2024-05-20
- 2.2.21 — 2024-04-24
- … 52 more at https://npm.io/package/@fluentui/react-window-provider/versions

## README

# @fluentui/react-window-provider

A set of utilities for providing and consuming the `window` and `document` references in a contextual scope.

## Why is this needed?

When rendering on the main browser window, many components need access to `window` or `document` for applying styling, listening for events, or measuring things. However it is possible to render to child windows and elements hosted in `iframe` elements.

In these cases, the target element is hosted in a different context, and thus have a different `window` reference. To aid in providing components with the correct instances of `window` or `document`, React context can be used to provide the tree of React components with the correct instance.

## Usage

To consume the window or document object, call `useWindow` or `useDocument` respectively:

```jsx
const Foo = () => {
  const win = useWindow();
  const doc = useDocument();

  return </>
}
```

To provide a new window other than the default, wrap your app in the `WindowProvider` to override the defaults contextually:

```jsx
import { createRoot } from 'react-dom/client';

createRoot(childWindowElement).render(
  <WindowProvider window={childWindow}>
    <...>
  </WindowProvider>,
);
```

---
_Source: https://npm.io/package/@fluentui/react-window-provider · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
