# react-viewport-height

> A utility for React to set 100vh equal to the actual browser inner window height.

Latest version **1.2.2** (published 2023-07-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-viewport-height
pnpm add react-viewport-height
yarn add react-viewport-height
bun add react-viewport-height
```

## Health

**Score 40/100 (D)** — status: abandoned.

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

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2023-07-31 |
| First published | 2020-11-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Author | Dima Zuien |
| Maintainers | dimazuien |
| Keywords | react, hook, viewport, scroll, vh, resize, window, screen, mobile |

## Links

- npm: https://www.npmjs.com/package/react-viewport-height
- Repository: https://github.com/dimazuien/react-viewport-height
- Homepage: https://github.com/dimazuien/react-viewport-height#readme
- Issues: https://github.com/dimazuien/react-viewport-height/issues
- Funding: https://www.patreon.com/dimazuien
- npm.io page: https://npm.io/package/react-viewport-height

## 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.2.2 (latest) — 2023-07-31
- 1.2.1 — 2022-07-17
- 1.2.0 — 2022-04-03
- 1.1.3 — 2021-02-22
- 1.1.2 — 2021-02-22
- 1.1.1 — 2021-02-22
- 1.1.0 — 2020-12-27
- 1.0.0 — 2020-11-02

## README

# react-viewport-height

[![npm Version](https://img.shields.io/npm/v/react-viewport-height.svg)](https://www.npmjs.com/package/react-viewport-height)
![npm downloads per week](https://img.shields.io/npm/dw/react-viewport-height)
![Minified size](https://img.shields.io/bundlephobia/min/react-viewport-height)
[![Open issues](https://img.shields.io/github/issues-raw/dimazuien/react-viewport-height)](https://github.com/dimazuien/react-viewport-height/issues)
[![Open pull requests](https://img.shields.io/github/issues-pr-raw/dimazuien/react-viewport-height)](https://github.com/dimazuien/react-viewport-height/pulls)
[![GitHub Stars](https://img.shields.io/github/stars/dimazuien/react-viewport-height)](https://github.com/dimazuien/react-viewport-height/stargazers)
![CircleCI status](https://img.shields.io/circleci/build/github/dimazuien/react-viewport-height/main?label=circleci)
![Code scanning](https://img.shields.io/github/workflow/status/dimazuien/react-viewport-height/CodeQL?label=code%20scanning)

A utility for React to set 100vh equal to the actual browser inner window height.

Since `vh` has troubles on mobile browsers (primarily because of the address bar), there are several tricks to fix it. This package implements the one from [this article](https://css-tricks.com/the-trick-to-viewport-units-on-mobile/).

_The solution for this was introduced in the [CSS Values and Units Module Level 4](https://www.w3.org/TR/css-values-4) which is [widely supported now](https://caniuse.com/viewport-unit-variants). Instead of using this package, you can use the `dvh` unit if your project doesn't need to support older browsers. [Read more about new units.](https://web.dev/viewport-units/)_

## Usage

```shell
npm install react-viewport-height
```

```jsx
// index.js
import useVH from 'react-viewport-height';
import './index.css';

const App = () => {
  useVH();

  return <div className="app" />;
};
```

```css
/* index.css */
.app {
  min-height: calc(var(--vh, 1vh) * 100);
}
```

Read [the documentation](https://github.com/dimazuien/react-viewport-height/blob/main/docs/index.md) for more details. You can also play with a [demo](https://codesandbox.io/s/react-viewport-height-90o4j).

## Support

If you like this package and want to support it, you can do it on [Patreon](https://www.patreon.com/dimazuien)

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