Gathering detailed insights and metrics for react-ipdf-viewer-lite
Gathering detailed insights and metrics for react-ipdf-viewer-lite
Gathering detailed insights and metrics for react-ipdf-viewer-lite
Gathering detailed insights and metrics for react-ipdf-viewer-lite
npm install react-ipdf-viewer-lite
Typescript
Module System
Node Version
NPM Version
TypeScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
1 Stars
14 Commits
2 Branches
1 Contributors
Updated on Jun 26, 2025
Latest Version
1.1.1
Package Id
react-ipdf-viewer-lite@1.1.1
Unpacked Size
50.65 kB
Size
12.26 kB
File Count
25
NPM Version
10.2.0
Node Version
21.0.0
Published on
Jun 27, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
3
2
A React component for viewing PDF documents using Mozilla's pdf.js
. Embed a customizable PDF viewer in your React applications with page zoom, theme, Full Screen, Page Count and download support.
Explore a live demo of react-ipdf-viewer-lite
in action:
See the PDF viewer with zoom, navigation, and theme support directly in your browser.
Install the package via npm:
1npm install react-ipdf-viewer-lite
Or using Yarn:
1yarn add react-ipdf-viewer-lite
Ensure you have the following peer dependencies installed:
react
(>=16.8.0)react-dom
(>=16.8.0)pdfjs-dist
(>=2.9.359)Install them if needed:
1npm install react react-dom pdfjs-dist
Import the ReactIPdfViewerLite
component and provide a PDF file URL or path via the src
prop. The component supports PDF documents only; place local PDFs in your public/
folder or use a hosted URL.
1import React from "react"; 2import { ReactIPdfViewerLite } from "react-ipdf-viewer-lite"; 3import "./App.css"; 4 5const PDF = "sample.pdf"; 6 7const App = () => { 8 return ( 9 <div className="App"> 10 <ReactIPdfViewerLite src={PDF} theme='light'/> 11 </div> 12 ); 13}; 14 15export default App;
ReactIPdfViewerLite
A React component to render a PDF viewer with customizable controls.
Prop | Type | Description | Default | Example |
---|---|---|---|---|
src | string | URL or path to the PDF file to render. Also accepts document={{ url }} . | None | 'sample.pdf' or 'https://example.com/sample.pdf' |
theme | string | Sets the viewer’s theme. Options: 'light' , 'dark' . | 'dark' | 'light' |
The ReactIPdfViewerLite
component may encounter issues when loading or rendering PDFs. Below are common errors and solutions.
Invalid PDF URL
src
prop points to an invalid or inaccessible URL.public/
or a hosted HTTPS URL.1<ReactIPdfViewer src="/sample.pdf" />
CORS Restrictions
public/
.1const App = () => { 2 const pdfUrl = 3 process.env.NODE_ENV === "development" 4 ? "/sample.pdf" 5 : "https://your-domain.com/sample.pdf"; 6 return <ReactIPdfViewerLite src={pdfUrl} />; 7};
Content Security Policy (CSP) Error
pdf.js
are blocked by your app’s CSP.connect-src
directive.
1<meta 2 http-equiv="Content-Security-Policy" 3 content="connect-src 'self' blob:;" 4/>
Mobile Rendering Issues
pdf.js
canvas rendering. Test with a local PDF.1<ReactIPdfViewerLite src="/sample.pdf" autoHeight />
File Loading Failure
Error: "PDF.js: Failed to fetch" or "Corrupted PDF".
Cause: The PDF file is corrupted or unsupported by pdf.js
.
Solution: Validate the PDF with Adobe Acrobat. Use a try-catch block for error handling.
Example:
1import React, { useState } from "react"; 2import {ReactIPdfViewerLite} from "react-ipdf-viewer-lite"; 3 4const App = () => { 5 const [error, setError] = useState(null); 6 const handleError = (err) => setError(err.message); 7 8 return ( 9 <div> 10 {error ? <p>Error: {error}</p> : null} 11 <ReactIPdfViewerLite 12 src="sample.pdf" 13 /> 14 </div> 15 ); 16};
src
is a valid string. Use a fallback URL if needed.
1const pdfUrl = src || "/fallback.pdf"; 2<ReactIPdfViewer src={pdfUrl} />;
onError
(if supported) or wrap in try-catch.pdf.js
warnings (e.g., missing CMaps).Beyond the core props, ReactIPdfViewerLite
offers:
Contributions are welcome! To contribute:
git checkout -b feature/YourFeature
).git commit -m 'Add YourFeature'
).git push origin feature/YourFeature
).Please ensure your code follows the existing style and includes tests where applicable.
This project is licensed under the MIT License. See the LICENSE file for details.
For issues, questions, or feature requests, please open an issue on the GitHub repository or contact Sudeepa R.# react-ipdf-viewer
No vulnerabilities found.
No security vulnerabilities found.