Skip to content

How to use pdf.js-dist in next js #17522

@Harsh-Sharma25

Description

@Harsh-Sharma25

How to configure pdf.js-dist to be able to run in next js
next-js version:- 12.3.1

This is the error I get:

./node_modules/pdfjs-dist/build/pdf.mjs
Module parse failed: The top-level-await experiment is not enabled (set experiments.topLevelAwait: true to enabled it)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders

Error: The top-level-await experiment is not enabled (set experiments.topLevelAwait: true to enabled it)

Even after enabling this in next-js config experiments.topLevelAwait. I still get the same error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions