diegomura / diegomura/react-pdf

React-pdf/renderer fails with "failed to asynchronously prepare wasm: CompileError" in TypeScript projects (CRA & Vite)

Open
#3,212 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
16.8k
Forks
1.3k
Avg merge
5h 6m
Merged PRs (30d)
52

Description

**Describe the bug**
Using @react-pdf/renderer in a TypeScript React project (CRA or Vite) fails to render PDF documents.
The PDFViewer iframe remains empty, and the console shows the following error:

failed to asynchronously prepare wasm: CompileError

**To Reproduce**
Steps to reproduce the behavior:

1. Create a new React project with TypeScript using CRA or Vite.
2. Install `@react-pdf/renderer`.
3. Import `Document`, `Page`, `Text`, and `PDFViewer` from `@react-pdf/renderer`.
4. Render a simple PDF using ``

5. Run `npm start` (CRA) or `npm run dev` (Vite).
6. Open the browser and check the console.

**Expected behavior**
The PDF should render inside the PDFViewer iframe (empty).

Image

Image

**Screenshots**
Image
Image
Image

**Desktop (please complete the following information):**

- OS: Windows / Linux
- Browser : Chrome / Zen Browser ( Firefox based )
- React-pdf version 4.3.0

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure in a TypeScript React project created with CRA and Vite, using @react-pdf/renderer 4.3.0 and PDFViewer. Start by tracing how the package prepares WebAssembly in the browser; done means the PDF renders inside the PDFViewer iframe without the asynchronous WASM CompileError.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript, wasm
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.