PDFViewer is not a web specific API
Unanswered
Rule posted this in #help-forum
RuleOP
Hi. I'm using
The package itself is working completely fine (it renders) but it's throwing an error for some reason:
@react-pdf/renderer for showing pdf in my next.js app with app directory.The package itself is working completely fine (it renders) but it's throwing an error for some reason:
"use client"
const Preview = () => {
return (
<PDFViewer className="w-full h-full" showToolbar={false}>
<SalesInvoiceEditorPDFPreview data={{}} />
</PDFViewer>
);
}; X ../node_modules/@react-pdf/renderer/lib/react-pdf.cjs.js (4368:0) @ throwEnvironmentError
X Internal error: Error: PDFViewer is a web specific API. You're either using this component on Node, or your bundler is not loading react-pdf from the appropriate web build.
at throwEnvironmentError (../node_modules/@react-pdf/renderer/lib/react-pdf.cjs.js:4368:9)
at PDFViewer (../node_modules/@react-pdf/renderer/lib/react-pdf.cjs.js:4374:3)4 Replies
@joulev you may want to import the pdf components using `next/dynamic` with `ssr: false`
RuleOP
Sorry I forgot to include this, but I tried to do that but it threw the same error and also then "client side expection occurred"
hmm then idk sorry. never used this lib
RuleOP
Yep. Thanks anyways