https://github.com/pdf-viewer-react/starter-rp-gatsby-js
React PDF Starter toolkit with Gatsby + JavaScript
https://github.com/pdf-viewer-react/starter-rp-gatsby-js
gatsby gatsbyjs javascript pdf-viewer pdf-viewer-react pdfjs pdfjs-dist react-pdf react-pdf-viewer reactjs
Last synced: 10 months ago
JSON representation
React PDF Starter toolkit with Gatsby + JavaScript
- Host: GitHub
- URL: https://github.com/pdf-viewer-react/starter-rp-gatsby-js
- Owner: pdf-viewer-react
- Created: 2025-08-07T02:27:23.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-08-15T02:55:56.000Z (10 months ago)
- Last Synced: 2025-08-15T04:26:39.120Z (10 months ago)
- Topics: gatsby, gatsbyjs, javascript, pdf-viewer, pdf-viewer-react, pdfjs, pdfjs-dist, react-pdf, react-pdf-viewer, reactjs
- Language: JavaScript
- Homepage: https://www.react-pdf.dev/
- Size: 73.2 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 Gatsby and JavaScript
[](https://codesandbox.io/p/devbox/exciting-orla-6m74z8)
Welcome to the React PDF Starter Toolkit! This repository provides a comprehensive guide on integrating React PDF with Gatsby and JavaScript. 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/pdf-viewer-react/starter-rpv-gatsby-js.git
cd starter-rpv-gatsby-js
```
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:8000` (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
```jsx
import React from "react"
import {
RPProvider,
RPDefaultLayout,
RPPages,
} from "@pdf-viewer/react";
const AppPdfViewer = (props) => {
const { showToolbar = true, providerProps, defaultLayoutProps } = props;
return (
{showToolbar ? (
) : (
)}
);
};
```
2. **Lazy Load the PDF Viewer Component**: Use React's lazy function to load the AppPdfViewer component only when it's needed
```jsx
import React from "react"
export const LazyAppPdfViewer = React.lazy(()=> import("./AppPdfViewer"))
```
3. **Use the component in the page**: Add the React PDF component to your page
```jsx
import React from "react";
import { LazyAppPdfViewer } from "../components/LazyAppPdfViewer";
import { RPConfig } from "@pdf-viewer/react";
const IndexPage = () => {
const isSSR = typeof window === "undefined";
return (
<>
{!isSSR && (
}>
RP Starter Toolkit: Gatsby + JavaScript
Default Toolbar
Without Toolbar
Mobile
)}
>
);
};
```
## Examples
For more examples, please refer to the `src/pages/index.jsx` 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!