Skip to main content


The useDocuments hook is used for loading and displaying a list of the current users documents.


Please note that this hook maintains a global state. All instances of this hook will return the same array of documents. This means that if you call loadAll, the loaded documents will be populated across all instances of the hook.


  • options (object) Options for the hook. Optional
    • options.sortBy ('createdAt' | 'updatedAt' | 'unreadCount') How to sort the documents. Defaults to 'updatedAt'
    • options.initialLoad (number | 'all') How many documents to load when the the hook is first mounted. Pass "all" to load all the documents. If not provided, no documents will be loaded until a loader function is manually called.


Returns an object with the following properties:

  • loadMore ((count: number) => Promise<void>) A function that can be called to load more documents. Accepts a number as as parameter which determines how many more documents to load.
  • loadAll (() => Promise<void>) A function that can be called to load all a users documents
  • loading (boolean) A boolean representing if documents are currently being loaded or not
  • documents (Document[]) An array of loaded documents
import { useDocuments } from '@pdftron/collab-react'
export function DocumentsList() {
const {
} = useDocuments({ initialLoad: 5 });
return (
<p>My documents<p>
{ => {
const isActive = document.isActive;
return (
<div key={} onClick={() => document.view(`document_url_here`)}>
<p style={{ fontWeight: isActive ? 'bold' : 'normal' }}>
<button onClick={() => loadMore(10)}>Load more</button>
<button onClick={() => loadAll()}>Load all</button>