
Research
/Security News
Chrome and Firefox Extensions Posing as Free VPNs Add Clipboard Stealers via Malicious Updates
Malicious Chrome and Firefox extensions posed as free VPNs while stealing clipboard data through later extension updates.
@react-pdf-kit/viewer
Advanced tools
A react-pdf-viewer component for React and Next.js. Suitable for react-pdf document.
As developers ourselves, we faced many issues such as browser incompatibility and customizability while trying to render a PDF document or working with PDF libraries. Having faced issues using PDF libraries, we want the solution to be flexible for React.js developers and teams. More importantly, the technical document must be easy to use!
For the full feature set, visit React PDF Features.
Here’s how to get started with React PDF in your React.js project:
Here are the basic system requirements to run the React PDF component:
If you are working with a React framework such as Next and Gatsby, React PDF can run smoothly as long as you are using React 18 and above.
React PDF viewer also works well with other React.js UI libraries such as MUI, Ant Design and Chakra UI.
Although React PDF can run on most JavaScript module bundlers, it is more vigorously tested on Vite and Webpack.
Remark:
- If using TypeScript, it requires >= TypeScript 4.6.
| Chrome | Firefox | Edge | Safari | Safari iOS | Chrome Android |
|---|---|---|---|---|---|
| 115+ | 115+ | 115+ | 16.5+ | 16.5+ | 126+ |
There are a few ways you can install React PDF, namely bun, npm, pnpm or yarn.
bun add @react-pdf-kit/viewer
bunTo clear cache, try running bun pm cache rm to remove cache in the global cache directory. If the error remains, try executing the following steps:
rm bun.lockb
rm -R node_modules
npm install @react-pdf-kit/viewer
yarn add @react-pdf-kit/viewer
pnpm add @react-pdf-kit/viewer
For more information on how to use different package managers, please visit our installation guide.
The following structure demonstrates how to build a React PDF viewer by importing and assembling components. This modular approach gives you the flexibility to customize the viewer as needed.
<RPConfig>
{' '}
{/* Configuration license and pdfjs-dist worker */}
<RPProvider>
{' '}
{/* Viewer context provider */}
<RPTheme>
{' '}
{/* Theme customization (optional) */}
<RPDefaultLayout>
{' '}
{/* Default layout container */}
<RPPages /> {/* PDF pages renderer */}
</RPDefaultLayout>
</RPTheme>
</RPProvider>
</RPConfig>
Remark: For more information on each component, please refer to Component.
The most basic usage of React PDF viewer needs four components, namely: RPConfig, RPProvider, RPDefaultLayout, and RPPages.
Here's how to implement a basic PDF viewer in a React application:
import { RPProvider, RPDefaultLayout, RPPages, RPConfig } from '@react-pdf-kit/viewer'
const App = () => {
return (
<RPConfig>
<RPProvider src="https://cdn.codewithmosh.com/image/upload/v1721763853/guides/web-roadmap.pdf">
<RPDefaultLayout style={{ height: '660px' }}>
<RPPages />
</RPDefaultLayout>
</RPProvider>
</RPConfig>
)
}
export default App
The PDF viewer will automatically adjust to fit its container's dimensions. You can control the size by setting the style prop on RPDefaultLayout. For more information on using React PDF, visit our basic usage guide
You may also check out our Starter Toolkit for examples to get you started.
To enhance React PDF further, we offer built-in hooks and props that let you fine-tune functionality, adjust appearance, and integrate custom behaviors into your application.
For detailed usage, refer to our Documentation.
Here are some sample projects to get started on React PDF quickly:
We are more than happy to help you. If you have any questions, run into any errors or face any problems, please feel free to create an issue in Issues or PM us directly in Twitter. Anything related to React PDF is on the table!
React PDF is distributed under our proprietary license. Please refer to our License page file for more details.
If you would like to use React PDF commercially, please purchase a license from our website or reach out to us directly at david@react-pdf.dev.
FAQs
A react-pdf-viewer component for React and Next.js. Suitable for react-pdf document.
The npm package @react-pdf-kit/viewer receives a total of 6,116 weekly downloads. As such, @react-pdf-kit/viewer popularity was classified as popular.
We found that @react-pdf-kit/viewer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Malicious Chrome and Firefox extensions posed as free VPNs while stealing clipboard data through later extension updates.

Research
/Security News
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.

Security News
Rolldown paused Rust React Compiler integration after a 5MB binary size increase raised concerns about shipping React-specific code to all Vite users.