{"id":31548705,"url":"https://github.com/premshree/use-pagination-firestore","last_synced_at":"2025-10-04T16:51:30.978Z","repository":{"id":38772460,"uuid":"272862737","full_name":"premshree/use-pagination-firestore","owner":"premshree","description":"🔥 React hook for non-cumulative pagination of Firebase Firestore collections","archived":false,"fork":false,"pushed_at":"2025-01-25T20:30:49.000Z","size":113,"stargazers_count":26,"open_issues_count":5,"forks_count":10,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-30T19:50:05.247Z","etag":null,"topics":["firebase","firestore","hooks","pagination","react","reacthooks"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/premshree.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-06-17T02:49:30.000Z","updated_at":"2025-08-11T12:52:35.000Z","dependencies_parsed_at":"2024-06-21T15:20:48.255Z","dependency_job_id":"a3be223c-b8a1-4611-8195-a2862aa00d6c","html_url":"https://github.com/premshree/use-pagination-firestore","commit_stats":{"total_commits":24,"total_committers":5,"mean_commits":4.8,"dds":0.5,"last_synced_commit":"82f4d8a9b25f6cc115dc2d3766077c25929b51a5"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/premshree/use-pagination-firestore","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/premshree%2Fuse-pagination-firestore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/premshree%2Fuse-pagination-firestore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/premshree%2Fuse-pagination-firestore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/premshree%2Fuse-pagination-firestore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/premshree","download_url":"https://codeload.github.com/premshree/use-pagination-firestore/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/premshree%2Fuse-pagination-firestore/sbom","scorecard":{"id":744523,"data":{"date":"2025-08-11","repo":{"name":"github.com/premshree/use-pagination-firestore","commit":"0b537a499e9d23827c44abbb560b362cfc822895"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.6,"checks":[{"name":"Code-Review","score":2,"reason":"Found 3/13 approved changesets -- score normalized to 2","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 23 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"12 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-7v5v-9h63-cj86","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-3wf4-68gx-mph8","Warn: Project is vulnerable to: GHSA-36fh-84j7-cv5h","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g","Warn: Project is vulnerable to: GHSA-g954-5hwp-pp24","Warn: Project is vulnerable to: GHSA-h755-8qp9-cq85","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-22T18:21:23.906Z","repository_id":38772460,"created_at":"2025-08-22T18:21:23.906Z","updated_at":"2025-08-22T18:21:23.906Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278343086,"owners_count":25971399,"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","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["firebase","firestore","hooks","pagination","react","reacthooks"],"created_at":"2025-10-04T16:51:26.755Z","updated_at":"2025-10-04T16:51:30.944Z","avatar_url":"https://github.com/premshree.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# use-pagination-firestore\n\nA React Hook that makes it easy to paginate firestore collections.\nThis hook is similar, but the not the same as\n[firestore-pagination-hook](https://github.com/bmcmahen/firestore-pagination-hook). This hook\nprovides _non cumulative_ pagination and does _not_ maintain references to previous\ndocuments, so it might be suitable for large document sets.\n\n## Support for Firebase 9\n\nVersions 0.6.x add support for Firebase 9 and are backwards _incompatible_ with previous versions of Firebase. For support for Firebase 8.x, use versions 5.x of `use-pagination-firestore`.\n\n## Install\n\n```\nnpm install use-pagination-firestore\n```\n\n## Example Use\n\nThis is an example of a \"recently added perfumes\" section built using [Material UI](https://material-ui.com/)\nand [Firestore](https://firebase.google.com/docs/firestore/). You can see it live on the Petrichor homepage [here](https://petrichor.se/), or\n[here](https://imgur.com/a/nUrgzaO) is a screencast.\n\n```jsx\nimport React from 'react';\nimport Grid from \"@material-ui/core/Grid\";\nimport PerfumeCard from \"./search/PerfumeCard\";\nimport { usePagination } from \"use-pagination-firestore\";\nimport Loading from \"./Loading\";\nimport {\n    NavigateNext as NavgateNextIcon,\n    NavigateBefore as NavigateBeforeIcon\n} from '@material-ui/icons';\nimport { IconButton } from \"@material-ui/core\";\nimport { initializeApp } from \"firebase/app\";\nimport { getFirestore, collection, query, orderBy } from \"firebase/firestore\";\n\nconst firebaseApp = initializeApp(firebaseConfig);\nconst db = getFirestore(firebaseApp);\n\nconst RecentPerfumes = () =\u003e {\n    const {\n        items,\n        isLoading,\n        isStart,\n        isEnd,\n        getPrev,\n        getNext,\n    } = usePagination\u003cPerfume\u003e(\n        query(collection(db, \"/perfumes\"), orderBy(\"updated\", \"desc\")),\n        {\n            limit: 10\n        }\n    );\n\n    if (isLoading) {\n        return \u003cLoading/\u003e;\n    }\n\n    return (\n        \u003cGrid container\u003e\n            \u003cGrid item xs={12}\u003e\n                \u003cGrid container justify=\"flex-end\"\u003e\n                    \u003cGrid item\u003e\n                        \u003cIconButton onClick={getPrev} disabled={isStart}\u003e\n                            \u003cNavigateBeforeIcon/\u003e\n                        \u003c/IconButton\u003e\n                        \u003cIconButton onClick={getNext} disabled={isEnd}\u003e\n                            \u003cNavgateNextIcon/\u003e\n                        \u003c/IconButton\u003e\n                    \u003c/Grid\u003e\n                \u003c/Grid\u003e\n            \u003c/Grid\u003e\n            {items.map((perfume, idx) =\u003e {\n                return (\n                    \u003cGrid item xs={12} sm={12} md={6} lg={6} key={`recent-perfume-${idx}`}\u003e\n                        \u003cPerfumeCard perfume={perfume} size=\"medium\"/\u003e\n                    \u003c/Grid\u003e\n                );\n            })}\n        \u003c/Grid\u003e\n    );\n}\n\nexport default RecentPerfumes;\n```\n\nYou can also change query during runtime. Hook will detect new query and start pagination from the beginning.\nHere is an example of controlling query's `limit` and `orderDirection` by React's state:\n\n```jsx\ntype ORDER_DIRECTION = 'asc' | 'desc';\nconst DEFAULT_PAGE_SIZE = 10;\n\nconst RecentPerfumes = () =\u003e {\n    const [pageSize, setPageSize] = useState(DEFAULT_PAGE_SIZE);\n    const [order, setOrder] = useState\u003cORDER_DIRECTION\u003e('desc');\n    const {\n        items,\n        isLoading,\n        isStart,\n        isEnd,\n        getPrev,\n        getNext,\n        currentPage,\n    } = usePagination\u003cPerfume\u003e(\n        query(collection(db, \"/perfumes\"), orderBy(\"updated\", \"desc\")),\n        {\n            limit: pageSize\n        }\n    );\n\n    if (isLoading) {\n        return \u003cLoading/\u003e;\n    }\n\n    return (\n        \u003cGrid container\u003e\n            \u003cGrid item xs={12}\u003e\n                \u003cGrid container justify=\"flex-end\"\u003e\n                    \u003cGrid item\u003e\n                        \u003cPageSizeSelect pageSize={pageSize} onChange={setPageSize} /\u003e\n                        \u003cOrderDirectionSelect order={order} onChange={setOrder} /\u003e\n                        \u003cIconButton onClick={getPrev} disabled={isStart}\u003e\n                            \u003cNavigateBeforeIcon/\u003e\n                        \u003c/IconButton\u003e\n                        \u003cBox component=\"span\"\u003ePage {currentPage}\u003c/Box\u003e\n                        \u003cIconButton onClick={getNext} disabled={isEnd}\u003e\n                            \u003cNavgateNextIcon/\u003e\n                        \u003c/IconButton\u003e\n                    \u003c/Grid\u003e\n                \u003c/Grid\u003e\n            \u003c/Grid\u003e\n            {items.map((perfume, idx) =\u003e {\n                return (\n                    \u003cGrid item xs={12} sm={12} md={6} lg={6} key={`recent-perfume-${idx}`}\u003e\n                        \u003cPerfumeCard perfume={perfume} size=\"medium\"/\u003e\n                    \u003c/Grid\u003e\n                );\n            })}\n        \u003c/Grid\u003e\n    );\n}\n```\n## Caveats\n\nPaginating Firestore documents relies on [query cursors](https://firebase.google.com/docs/firestore/query-data/query-cursors). It's not easy to know\nahead of time how many documents exist in a collection. Consequently, if your `document_count % page_size` is `0` you will notice that your last page\nis empty – this is because this hook doesn't (currently) look ahead to know if there are any more documents. ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpremshree%2Fuse-pagination-firestore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpremshree%2Fuse-pagination-firestore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpremshree%2Fuse-pagination-firestore/lists"}