score:2

Accepted answer

since your pdf file is located in the public folder, you can reference the image's path directly in the filepath prop.

you also need to make sure react-file-viewer is only imported in the browser as it depends on window being present to work properly. you can do so by dynamically importing the component through next/dynamic with ssr: false.

import dynamic from 'next/dynamic';

const fileviewer = dynamic(() => import('react-file-viewer'), {
    ssr: false
});

export default function index() {
    return (
        <fileviewer filetype="pdf" filepath="/pdf.pdf" />
    );
};

Related Query

More Query from same tag