
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
@examind/use-pagination-firestore
Advanced tools
A non-cumulative pagination hook for use with Firestore
A React Hook that makes it easy to paginate firestore collections. This hook is similar, but the not the same as firestore-pagination-hook. This hook provides non cumulative pagination and does not maintain references to previous documents, so it might be suitable for large document sets.
Versions 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.
npm install use-pagination-firestore
This is an example of a "recently added perfumes" section built using Material UI and Firestore. You can see it live on the Petrichor homepage here, or here is a screencast.
import React from 'react';
import Grid from '@material-ui/core/Grid';
import PerfumeCard from './search/PerfumeCard';
import { usePagination } from 'use-pagination-firestore';
import Loading from './Loading';
import { NavigateNext as NavgateNextIcon, NavigateBefore as NavigateBeforeIcon } from '@material-ui/icons';
import { IconButton } from '@material-ui/core';
import { initializeApp } from 'firebase/app';
import { getFirestore, collection, query, orderBy } from 'firebase/firestore';
const firebaseApp = initializeApp(firebaseConfig);
const db = getFirestore(firebaseApp);
const RecentPerfumes = () => {
const { items, isLoading, isStart, isEnd, getPrev, getNext } =
usePagination <
Perfume >
(query(collection(db, '/perfumes'), orderBy('updated', 'desc')),
{
limit: 10,
});
if (isLoading) {
return <Loading />;
}
return (
<Grid container>
<Grid item xs={12}>
<Grid container justify="flex-end">
<Grid item>
<IconButton onClick={getPrev} disabled={isStart}>
<NavigateBeforeIcon />
</IconButton>
<IconButton onClick={getNext} disabled={isEnd}>
<NavgateNextIcon />
</IconButton>
</Grid>
</Grid>
</Grid>
{items.map((perfume, idx) => {
return (
<Grid item xs={12} sm={12} md={6} lg={6} key={`recent-perfume-${idx}`}>
<PerfumeCard perfume={perfume} size="medium" />
</Grid>
);
})}
</Grid>
);
};
export default RecentPerfumes;
You can also change query during runtime. Hook will detect new query and start pagination from the beginning.
Here is an example of controlling query's limit and orderDirection by React's state:
type ORDER_DIRECTION = 'asc' | 'desc';
const DEFAULT_PAGE_SIZE = 10;
const RecentPerfumes = () => {
const [pageSize, setPageSize] = useState(DEFAULT_PAGE_SIZE);
const [order, setOrder] = useState<ORDER_DIRECTION>('desc');
const {
items,
isLoading,
isStart,
isEnd,
getPrev,
getNext,
currentPage,
} = usePagination<Perfume>(
query(collection(db, "/perfumes"), orderBy("updated", "desc")),
{
limit: pageSize
}
);
if (isLoading) {
return <Loading/>;
}
return (
<Grid container>
<Grid item xs={12}>
<Grid container justify="flex-end">
<Grid item>
<PageSizeSelect pageSize={pageSize} onChange={setPageSize} />
<OrderDirectionSelect order={order} onChange={setOrder} />
<IconButton onClick={getPrev} disabled={isStart}>
<NavigateBeforeIcon/>
</IconButton>
<Box component="span">Page {currentPage}</Box>
<IconButton onClick={getNext} disabled={isEnd}>
<NavgateNextIcon/>
</IconButton>
</Grid>
</Grid>
</Grid>
{items.map((perfume, idx) => {
return (
<Grid item xs={12} sm={12} md={6} lg={6} key={`recent-perfume-${idx}`}>
<PerfumeCard perfume={perfume} size="medium"/>
</Grid>
);
})}
</Grid>
);
}
Paginating Firestore documents relies on query cursors. It's not easy to know
ahead 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
is empty – this is because this hook doesn't (currently) look ahead to know if there are any more documents.
npm installRelease {version, e.g. 0.1.6}FAQs
A non-cumulative pagination hook for use with Firestore
We found that @examind/use-pagination-firestore demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.