{"id":13450551,"url":"https://github.com/neo/react-use-scroll-position","last_synced_at":"2025-06-22T05:34:47.355Z","repository":{"id":57347196,"uuid":"166564110","full_name":"neo/react-use-scroll-position","owner":"neo","description":"A react hook to use scroll position","archived":false,"fork":false,"pushed_at":"2019-06-01T17:50:06.000Z","size":14,"stargazers_count":46,"open_issues_count":2,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-15T04:47:30.405Z","etag":null,"topics":["react","react-hook","react-hooks","scroll"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/neo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-19T15:50:42.000Z","updated_at":"2024-06-15T22:01:38.000Z","dependencies_parsed_at":"2022-09-18T11:24:02.183Z","dependency_job_id":null,"html_url":"https://github.com/neo/react-use-scroll-position","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/neo/react-use-scroll-position","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neo%2Freact-use-scroll-position","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neo%2Freact-use-scroll-position/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neo%2Freact-use-scroll-position/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neo%2Freact-use-scroll-position/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neo","download_url":"https://codeload.github.com/neo/react-use-scroll-position/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neo%2Freact-use-scroll-position/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261243140,"owners_count":23129590,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["react","react-hook","react-hooks","scroll"],"created_at":"2024-07-31T07:00:35.993Z","updated_at":"2025-06-22T05:34:42.336Z","avatar_url":"https://github.com/neo.png","language":"TypeScript","readme":"# react-use-scroll-position\n\n[![npm package](https://img.shields.io/npm/v/react-use-scroll-position.svg)](https://www.npmjs.com/package/react-use-scroll-position) ![](https://img.shields.io/npm/types/react-use-scroll-position.svg)\n\nA [react hook](https://reactjs.org/docs/hooks-intro.html) to use scroll position.\n\n## Usage\n\n### In a React functional component:\n\n```tsx\nimport React from 'react';\n// Usually you would just need to import one of the following\nimport { useScrollPosition, useScrollXPosition, useScrollYPosition } from 'react-use-scroll-position';\n\nfunction Example() {\n  const { x, y } = useScrollPosition();\n  const scrollX = useScrollXPosition();\n  const scrollY = useScrollYPosition();\n  return (\n    \u003c\u003e\n      \u003cp\u003e\n        {x} should equal to {scrollX}.\n      \u003c/p\u003e\n      \u003cp\u003e\n        {y} should equal to {scrollY}.\n      \u003c/p\u003e\n    \u003c/\u003e\n  );\n}\n```\n\n### In a custom React hook\n\n```tsx\nimport { useScrollPosition } from 'react-use-scroll-position';\n\nfunction useYourImagination() {\n  const { x, y } = useScrollPosition();\n  return getSomethingAwesomeWith(x, y);\n}\n```\n\n# Implementation details\n\nThe scroll event handler is throttled by `requestAnimationFrame`.\n","funding_links":[],"categories":["Packages"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneo%2Freact-use-scroll-position","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneo%2Freact-use-scroll-position","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneo%2Freact-use-scroll-position/lists"}