https://github.com/pdf-viewer-react/starter-rp-react-ts-vite
React PDF Starter toolkit with React + TypeScript + Vite
https://github.com/pdf-viewer-react/starter-rp-react-ts-vite
pdf-viewer pdf-viewer-react pdfjs pdfjs-dist react-pdf react-pdf-viewer reactjs typescript vite
Last synced: 7 months ago
JSON representation
React PDF Starter toolkit with React + TypeScript + Vite
- Host: GitHub
- URL: https://github.com/pdf-viewer-react/starter-rp-react-ts-vite
- Owner: pdf-viewer-react
- Created: 2025-02-04T03:05:42.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-28T07:55:31.000Z (12 months ago)
- Last Synced: 2025-02-28T11:18:18.865Z (12 months ago)
- Topics: pdf-viewer, pdf-viewer-react, pdfjs, pdfjs-dist, react-pdf, react-pdf-viewer, reactjs, typescript, vite
- Language: TypeScript
- Homepage: https://www.react-pdf.dev
- Size: 46.9 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# React PDF Starter Toolkit in React.js, TypeScript and Vite
[](https://stackblitz.com/github.com/pdf-viewer-react/starter-rp-react-ts-vite)
Welcome to the React PDF Starter Toolkit! This repository provides a comprehensive guide on integrating React PDF with React, TypeScript and Vite. It showcases how React PDF can be integrated and rendered as part of a React.js project.
## Table of Contents
- [Usage](#usage)
- [Project Setup](#project-setup)
- [Running the Example Project](#running-the-example-project)
- [Examples](#examples)
## Usage
### Project Setup
1. **Clone the Repository**: If you haven't already, clone the repository and navigate into the project directory.
```bash
git clone https://github.com/reactpdf/starter-rp-react-ts-vite.git
cd starter-rp-react-ts-vite
```
2. **Install Dependencies**: Install the necessary dependencies using npm, yarn, pnpm or bun.
```bash
npm install
# or
yarn install
# or
pnpm install
# or
bun install
```
### Running the Example Project
This repository includes an example project to demonstrate React PDF in action.
1. **Start the Development Server**: Use the following command to start the development server
```bash
npm run dev
# or
yarn dev
# or
pnpm run dev
# or
bun run dev
```
2. **Open in Browser**: Open your browser and navigate to `http://localhost:5173` (or the port specified in your terminal) to see the example project in action
### Using the React PDF Component
Once the example project is running, you can explore the source code to see how the React PDF component is integrated. Here is a brief overview:
1. **Import the component**: Import the desired React PDF component into your codes
```tsx
import {
RPProvider,
RPDefaultLayout,
RPPages,
RPProviderProps,
RPLayoutProps,
} from "@pdf-viewer/react";
interface Props {
showToolbar?: boolean;
providerProps?: RPProviderProps;
defaultLayoutProps?: RPLayoutProps;
}
export const AppPdfViewer = (props: Props) => {
const { showToolbar = true, providerProps, defaultLayoutProps } = props;
return (
{showToolbar ? (
) : (
)}
);
};
```
2. **Use the component in the page**: Add the React PDF component to your page
```tsx
import { RPConfig } from "@pdf-viewer/react";
import { AppPdfViewer } from "./components/AppPdfViewer";
function App() {
return (
RP Starter Toolkit: Vite + React
Default Toolbar
Without Toolbar
Mobile
);
}
export default App;
```
## Examples
For more examples, please refer to the `src/App.tsx` file in this repository:
- Default Toolbar
- Without Toolbar
- Mobile View
_Remark: If you would like more examples, feel free open an issue._
For more configurations, please check the [documentation](https://docs.react-pdf.dev) site.
## Meta
- Homepage: [https://www.react-pdf.dev](https://www.react-pdf.dev)
- Docs: [https://docs.react-pdf.dev](https://docs.react-pdf.dev)
---
Thank you for using React PDF! We hope this toolkit helps you build amazing React.js applications. If you have any questions or need further assistance on this example, please feel free to open an issue. Happy coding!