New react-pdf 2.0 was relesed. Read about the announcement




usePDF Web only

React-pdf now ships a hook called usePDF that enables accessing all PDF creation capabilities via a React hook API. This is great if you need more control over how the document get's rendered or how often it's updated.


const [instance, update] = usePDF({ document });


Prop nameDescriptionDefault
documentDocument's root elementundefined

Instance object

Prop nameDescriptionDefault
urlRendered document blog url. Null if loading or erroredundefined
blobRendered document blob instance. Null if loading or erroredundefined
loadingLoading state. It's true if current render is in placefalse
errorError message if rendering failedundefined

Update function

Used to trigger a document re-render. By default, changing the document instance does not triggers a new PDF file creation. This is very helpful specially when just rendering a download button or similar, where you might want to render the document right before the action get's triggered.

The update function takes no arguments and does not return anything.

For more information about how this hook is used please refer to Using the usePDF hook section

← SVG Images