Next.js Discord

Discord Forum

Unable to use `@react-pdf/renderer` with next14

Unanswered
Naeemgg posted this in #help-forum
Open in Discord
Avatar
getting this error
Image

20 Replies

Avatar
its just a simple PDF with nothing fancy in it. it has some texts, links and a qrcode
Avatar
@Naeemgg getting this error
Avatar
remove the @react-pdf/renderer from your external packages list. If it's not there, import the component as client component. If the error still persists import the client component without SSR (lazy loading)
Avatar
@B33fb0n3 remove the @react-pdf/renderer from your external packages list. If it's not there, import the component as client component. If the error still persists import the client component without SSR (lazy loading)
Avatar
already importing like this
import React from 'react'

import dynamic from "next/dynamic";

const PdfGenerator = dynamic(() => import("@/app/components/React-PDF"), { ssr: false });
const page = () => {
  return (
    <div>
      <PdfGenerator />
    </div>
  )
}

export default page
Avatar
@Naeemgg it was in external packages, removed it
Avatar
remove it everywhere where external packages are. Then delete the .next folder and restart your app
Avatar
let me try
but in dev its giving the same error
Avatar
@Naeemgg but in dev its giving the same error
Avatar
did you restarted your dev server?
Avatar
@B33fb0n3 did you restarted your dev server?
Avatar
multiple times
deleted .next as well
Avatar
and you also remove it from the dev external packages (if they exists)?
Avatar
YEPP
I think I should roll back to jsPdf
I just wanted to try other pdf libraries
while jspdf is working just fine the margin,border,padding and these things are very time consuming
Avatar
yea, it looks like react-pdf is more a library for react only... and haven't been configured to work for other versions as well..
Avatar
I wanted to write once and use it for both web and PDF