# @react-typed-hooks/use-window-size

> React hook written in TypeScript

Latest version **1.0.5** (published 2020-12-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install @react-typed-hooks/use-window-size
pnpm add @react-typed-hooks/use-window-size
yarn add @react-typed-hooks/use-window-size
bun add @react-typed-hooks/use-window-size
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2020-12-06 |
| First published | 2020-06-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 8.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Christopher Dierkens |
| Maintainers | cjdierkens |
| Keywords | react, hooks, typescript |

## Links

- npm: https://www.npmjs.com/package/@react-typed-hooks/use-window-size
- Repository: https://github.com/react-typed-hooks/react-typed-hooks
- Homepage: https://github.com/react-typed-hooks/react-typed-hooks#readme
- Issues: https://github.com/react-typed-hooks/react-typed-hooks/issues
- npm.io page: https://npm.io/package/@react-typed-hooks/use-window-size

## Dependencies (3)

- [lodash](https://npm.io/package/lodash.md) ^4.17.15
- [@types/lodash](https://npm.io/package/@types/lodash.md) ^4.14.155
- [@react-typed-hooks/utils](https://npm.io/package/@react-typed-hooks/utils.md) ^1.0.5

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.5 (latest) — 2020-12-06
- 1.0.4 — 2020-12-05
- 1.0.3 — 2020-12-05
- 1.0.1 — 2020-12-05
- 1.0.0 — 2020-08-05
- 1.0.0-alpha.3 — 2020-06-25
- 1.0.0-alpha.2 — 2020-06-07
- 1.0.0-alpha.0 — 2020-06-06
- 0.1.1-alpha.0 — 2020-06-05

## README

# useWindowSize

React hook that returns the window size. Updates on window resize and orientation change.

![version](https://badgen.net/npm/v/@react-typed-hooks/use-window-size)

## Installation

```bash
npm install @react-typed-hooks/use-window-size
```

## Usage

```tsx
import { useWindowSize } from "@react-typed-hooks/use-window-size";

const Demo = () => {
  const size = useWindowSize();

  return size ? (
    <pre>JSON.stringify(size, null, 4)</pre>
  ) : (
    <span>Size is null in a node like environment</span>
  );
};
```

## API

### Types

```ts
interface Size {
  height: number;
  width: number;
}

interface UseWindowSizeOptions {
  wait?: number;
}
```

```ts
function useWindowSize(options?: UseWindowSizeOptions): Size | null;
```

### Options

`wait`

The amount of time to delay updating `Size` after the orientation changes.

The amount of time to throttle between updating `Size` when the window is resized.

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