File tree Expand file tree Collapse file tree 5 files changed +49
-1
lines changed Expand file tree Collapse file tree 5 files changed +49
-1
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ Add React-PDF to your project by executing `npm install react-pdf` or `yarn add
7474
7575#### Next.js
7676
77- If you use Next.js, you may need to add the following to your ` next.config.js ` :
77+ If you use Next.js without Turbopack enabled, add the following to your ` next.config.js ` :
7878
7979``` diff
8080module.exports = {
@@ -86,6 +86,26 @@ module.exports = {
8686}
8787```
8888
89+ If you use Next.js with Turbopack enabled, add ` empty-module.ts ` file:
90+
91+ ``` ts
92+ export default {};
93+ ```
94+
95+ and add the following to your ` next.config.js ` :
96+
97+ ``` diff
98+ module.exports = {
99+ + experimental: {
100+ + turbo: {
101+ + resolveAlias: {
102+ + canvas: './empty-module.ts',
103+ + },
104+ + },
105+ + },
106+ };
107+ ```
108+
89109### Configure PDF.js worker
90110
91111For React-PDF to work, PDF.js worker needs to be provided. You have several options.
Original file line number Diff line number Diff line change 1+ export { } ;
Original file line number Diff line number Diff line change 11/** @type {import('next').NextConfig } */
22const nextConfig = {
3+ experimental : {
4+ turbo : {
5+ resolveAlias : {
6+ // Turbopack does not support standard ESM import paths yet
7+ './Sample.js' : './app/Sample.tsx' ,
8+ /**
9+ * Critical: prevents " ⨯ ./node_modules/canvas/build/Release/canvas.node
10+ * Module parse failed: Unexpected character '�' (1:0)" error
11+ */
12+ canvas : './empty-module.ts' ,
13+ } ,
14+ } ,
15+ } ,
316 webpack : ( config ) => {
417 /**
518 * Critical: prevents " ⨯ ./node_modules/canvas/build/Release/canvas.node
Original file line number Diff line number Diff line change 1+ export { } ;
Original file line number Diff line number Diff line change 11/** @type {import('next').NextConfig } */
22const nextConfig = {
3+ experimental : {
4+ turbo : {
5+ resolveAlias : {
6+ // Turbopack does not support standard ESM import paths yet
7+ './Sample.js' : './pages/Sample.tsx' ,
8+ /**
9+ * Critical: prevents " ⨯ ./node_modules/canvas/build/Release/canvas.node
10+ * Module parse failed: Unexpected character '�' (1:0)" error
11+ */
12+ canvas : './empty-module.ts' ,
13+ } ,
14+ } ,
15+ } ,
316 webpack : ( config ) => {
417 /**
518 * Critical: prevents " ⨯ ./node_modules/canvas/build/Release/canvas.node
You can’t perform that action at this time.
0 commit comments