# react-router-scroll-to-top

> React component that scrolls to the top of a page when the current location gets changed

Latest version **2.0.0** (published 2026-11-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-router-scroll-to-top
pnpm add react-router-scroll-to-top
yarn add react-router-scroll-to-top
bun add react-router-scroll-to-top
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2026-11-27 |
| First published | 2020-10-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 0 |
| Author | Dima Zuien |
| Maintainers | dimazuien |
| Keywords | react, react router, scroll restoration, scroll, scroll to top |

## Links

- npm: https://www.npmjs.com/package/react-router-scroll-to-top
- Repository: https://github.com/dimazuien/react-router-scroll-to-top
- Homepage: https://github.com/dimazuien/react-router-scroll-to-top#readme
- Issues: https://github.com/dimazuien/react-router-scroll-to-top/issues
- npm.io page: https://npm.io/package/react-router-scroll-to-top

## 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

- 2.0.0 (latest) — 2026-11-27
- 1.3.0 — 2026-11-27
- 1.2.1 — 2023-07-31
- 1.2.0 — 2022-04-03
- 1.1.2 — 2021-02-22
- 1.1.1 — 2020-12-28
- 1.1.0 — 2020-12-27
- 1.0.0 — 2020-10-30

## README

# react-router-scroll-to-top

<!-- prettier-ignore-start -->
[![npm Version](https://img.shields.io/npm/v/react-router-scroll-to-top.svg)](https://www.npmjs.com/package/react-router-scroll-to-top)
![npm downloads per week](https://img.shields.io/npm/dw/react-router-scroll-to-top)
![Unpacked size](https://img.shields.io/npm/unpacked-size/react-router-scroll-to-top)
[![Open issues](https://img.shields.io/github/issues-raw/dimazuien/react-router-scroll-to-top)](https://github.com/dimazuien/react-router-scroll-to-top/issues)
[![Open pull requests](https://img.shields.io/github/issues-pr-raw/dimazuien/react-router-scroll-to-top)](https://github.com/dimazuien/react-router-scroll-to-top/pulls)
[![GitHub Stars](https://img.shields.io/github/stars/dimazuien/react-router-scroll-to-top)](https://github.com/dimazuien/react-router-scroll-to-top/stargazers)
![CI status](https://img.shields.io/github/actions/workflow/status/dimazuien/react-router-scroll-to-top/ci.yml?branch=main&label=ci)
![Code scanning](https://img.shields.io/github/actions/workflow/status/dimazuien/react-router-scroll-to-top/codeql-analysis.yml?branch=main)
<!-- prettier-ignore-end -->

ScrollToTop is a React component that scrolls to the top of the page when the location changes. It's for apps that use React Router 7 or 8 in declarative mode, with `<BrowserRouter>`, where React Router has no built-in scroll handling. For React Router 5.1 or 6, use version 1 of this package.

If your app uses a data router (`createBrowserRouter` with `<RouterProvider>`) or framework mode, use React Router's [`<ScrollRestoration>`](https://reactrouter.com/api/components/ScrollRestoration) instead. It also restores the scroll position when users go back or forward.

## Usage

```shell
npm install react-router-scroll-to-top
```

```jsx
import { BrowserRouter, Routes } from 'react-router';
import { ScrollToTop } from 'react-router-scroll-to-top';

const App = () => (
  <BrowserRouter>
    <ScrollToTop />
    <Routes>{/* routes */}</Routes>
  </BrowserRouter>
);
```

Read [the documentation](https://github.com/dimazuien/react-router-scroll-to-top/blob/main/docs/index.md) for more details. You can also play with a [demo](https://codesandbox.io/s/react-router-scroll-to-top-n1mg3).

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