{"id":30263144,"url":"https://github.com/pdf-viewer-react/starter-rp-gatsby-js","last_synced_at":"2025-08-15T21:06:08.848Z","repository":{"id":310000928,"uuid":"1033558996","full_name":"pdf-viewer-react/starter-rp-gatsby-js","owner":"pdf-viewer-react","description":"React PDF Starter toolkit with Gatsby + JavaScript ","archived":false,"fork":false,"pushed_at":"2025-08-15T02:55:56.000Z","size":75,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-15T04:26:39.120Z","etag":null,"topics":["gatsby","gatsbyjs","javascript","pdf-viewer","pdf-viewer-react","pdfjs","pdfjs-dist","react-pdf","react-pdf-viewer","reactjs"],"latest_commit_sha":null,"homepage":"https://www.react-pdf.dev/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pdf-viewer-react.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-07T02:27:23.000Z","updated_at":"2025-08-15T02:55:59.000Z","dependencies_parsed_at":"2025-08-15T04:26:49.922Z","dependency_job_id":"c076a26c-b352-45ff-8514-bef24de31619","html_url":"https://github.com/pdf-viewer-react/starter-rp-gatsby-js","commit_stats":null,"previous_names":["pdf-viewer-react/starter-rp-gatsby-js"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/pdf-viewer-react/starter-rp-gatsby-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pdf-viewer-react%2Fstarter-rp-gatsby-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pdf-viewer-react%2Fstarter-rp-gatsby-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pdf-viewer-react%2Fstarter-rp-gatsby-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pdf-viewer-react%2Fstarter-rp-gatsby-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pdf-viewer-react","download_url":"https://codeload.github.com/pdf-viewer-react/starter-rp-gatsby-js/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pdf-viewer-react%2Fstarter-rp-gatsby-js/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270631759,"owners_count":24619379,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-15T02:00:12.559Z","response_time":110,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gatsby","gatsbyjs","javascript","pdf-viewer","pdf-viewer-react","pdfjs","pdfjs-dist","react-pdf","react-pdf-viewer","reactjs"],"created_at":"2025-08-15T21:06:02.405Z","updated_at":"2025-08-15T21:06:08.840Z","avatar_url":"https://github.com/pdf-viewer-react.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React PDF Starter Toolkit in Gatsby and JavaScript\n\n\n[![Open example in codesandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/devbox/exciting-orla-6m74z8)\n\nWelcome 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.\n\n## Table of Contents\n\n- [Usage](#usage)\n  - [Project Setup](#project-setup)\n  - [Running the Example Project](#running-the-example-project)\n- [Examples](#examples)\n\n## Usage\n\n### Project Setup\n\n1. **Clone the Repository**: If you haven't already, clone the repository and navigate into the project directory.\n\n   ```bash\n   git clone https://github.com/pdf-viewer-react/starter-rpv-gatsby-js.git\n   cd starter-rpv-gatsby-js\n   ```\n\n2. **Install Dependencies**: Install the necessary dependencies using npm, yarn, pnpm or bun.\n\n   ```bash\n   npm install\n   # or\n   yarn install\n   # or\n   pnpm install\n   # or\n   bun install\n   ```\n\n### Running the Example Project\n\nThis repository includes an example project to demonstrate React PDF in action.\n\n1. **Start the Development Server**: Use the following command to start the development server\n\n   ```bash\n   npm run dev\n   # or\n   yarn dev\n   # or\n   pnpm run dev\n   # or\n   bun run dev\n   ```\n\n2. **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\n\n### Using the React PDF Component\n\nOnce 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:\n\n1.  **Import the component**: Import the desired React PDF component into your codes\n\n```jsx\nimport React from \"react\"\nimport {\n  RPProvider,\n  RPDefaultLayout,\n  RPPages,\n} from \"@pdf-viewer/react\";\n\nconst AppPdfViewer = (props) =\u003e {\n  const { showToolbar = true, providerProps, defaultLayoutProps } = props;\n\n  return (\n    \u003cRPProvider\n      src=\"https://cdn.codewithmosh.com/image/upload/v1721763853/guides/web-roadmap.pdf\"\n      {...providerProps}\n    \u003e\n      {showToolbar ? (\n        \u003cRPDefaultLayout {...defaultLayoutProps}\u003e\n          \u003cRPPages /\u003e\n        \u003c/RPDefaultLayout\u003e\n      ) : (\n        \u003cdiv style={{ width: \"100%\", height: \"550px\" }}\u003e\n          \u003cRPPages /\u003e\n        \u003c/div\u003e\n      )}\n    \u003c/RPProvider\u003e\n  );\n};\n```\n\n2. **Lazy Load the PDF Viewer Component**: Use React's lazy function to load the AppPdfViewer component only when it's needed\n\n```jsx\nimport React from \"react\"\n\nexport const LazyAppPdfViewer =  React.lazy(()=\u003e import(\"./AppPdfViewer\"))\n```\n\n3. **Use the component in the page**: Add the React PDF component to your page\n\n```jsx\nimport React from \"react\";\nimport { LazyAppPdfViewer } from \"../components/LazyAppPdfViewer\";\nimport { RPConfig } from \"@pdf-viewer/react\";\n\nconst IndexPage = () =\u003e {\n  const isSSR = typeof window === \"undefined\";\n  return (\n    \u003c\u003e\n      {!isSSR \u0026\u0026 (\n        \u003cReact.Suspense fallback={\u003cdiv /\u003e}\u003e\n          \u003cRPConfig\u003e\n            \u003cdiv className=\"container\"\u003e\n              \u003ch1\u003eRP Starter Toolkit: Gatsby + JavaScript\u003c/h1\u003e\n              \u003cbr /\u003e\n              \u003ch2\u003eDefault Toolbar\u003c/h2\u003e\n              \u003cLazyAppPdfViewer /\u003e\n              \u003ch2\u003eWithout Toolbar\u003c/h2\u003e\n              \u003cLazyAppPdfViewer\n                showToolbar={false}\n                defaultLayoutProps={{\n                  style: { width: \"100%\", height: \"550px\" },\n                }}\n              /\u003e\n              \u003ch2\u003eMobile\u003c/h2\u003e\n              \u003cLazyAppPdfViewer\n                defaultLayoutProps={{\n                  style: { width: \"500px\" },\n                }}\n              /\u003e\n            \u003c/div\u003e\n          \u003c/RPConfig\u003e\n        \u003c/React.Suspense\u003e\n      )}\n    \u003c/\u003e\n  );\n};\n```\n\n## Examples\n\nFor more examples, please refer to the `src/pages/index.jsx` file in this repository:\n\n- Default Toolbar\n- Without Toolbar\n- Mobile View\n\n_Remark: If you would like more examples, feel free open an issue._\n\nFor more configurations, please check the [documentation](https://docs.react-pdf.dev) site.\n\n## Meta\n\n- Homepage: [https://www.react-pdf.dev](https://www.react-pdf.dev)\n- Docs: [https://docs.react-pdf.dev](https://docs.react-pdf.dev)\n\n---\n\nThank 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!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpdf-viewer-react%2Fstarter-rp-gatsby-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpdf-viewer-react%2Fstarter-rp-gatsby-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpdf-viewer-react%2Fstarter-rp-gatsby-js/lists"}