Skip to content

Nextjs with useRouter #2331

@GubanovSergey

Description

@GubanovSergey

Describe the bug

https://previewjs.com/docs/guides/nextjs

npm i previewjs/config-helper-nextjs doesn't work since the repo is not publicly available.
Using custom implementation below the automatic results in an error:

TypeError: Cannot redefine property: default
at Function.defineProperty ()
at http://localhost:3140/__previewjs__/Wrapper.tsx?import&t=1703848410741:6:8

Reproduction

  1. const router = useRouter() will give an error that router is not mounted
  2. Defined previewjs folder with Wrapper.tsx file.
  3. Code from the link above

Preview.js version

v1.27.3

Framework

^18

System Info

System:
    OS: Windows 11 10.0.22621
    CPU: (16) x64 12th Gen Intel(R) Core(TM) i5-12500H
    Memory: 1.48 GB / 15.73 GB
  Binaries:
    Node: 20.10.0 - C:\Programs\nextjs\node.EXE
    npm: 10.2.5 - C:\Programs\nextjs\npm.CMD
  IDEs:
    VSCode: 1.85.1 - C:\Programs\Microsoft VS Code\bin\code.CMD
    Visual Studio: 17.7.34221.43 (Visual Studio Community 2022)
  Browsers:
    Edge: Chromium (119.0.2151.97)
    Internet Explorer: 11.0.22621.1

Used Package Manager

npm

Extension logs (useful for crashes)

No response

Preview logs (useful for rendering errors)

No response

Repo link (if available)

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions