You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[appDir] Dynamically importing a Client Component using the 'use client' directive from a Server Component causes "Error: object is not a function" #43147
I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 22.1.0: Sun Oct 9 20:14:30 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T8103
Binaries:
Node: 14.18.0
npm: 6.14.15
Yarn: 1.22.17
pnpm: 7.14.1
Relevant packages:
next: 13.0.5-canary.3
eslint-config-next: 13.0.5-canary.3
react: 18.2.0
react-dom: 18.2.0
What browser are you using? (if relevant)
Firefox 107.0
How are you deploying your application? (if relevant)
Vercel
Describe the Bug
Dynamically importing with next/dynamic a Client Component that uses a use/client directive will cause an Error: object is not a function error in development. The production build runs fine though.
Also noticed that adding ssr: false won't prevent the component from getting prerendered when running next build. Adding suspense: true or suspense: false won't make a difference either.
Expected Behavior
We should be able to dynamically import a component that makes heavy use of JavaScript in the client from a Server Component and use a custom Suspense-based fallback.
Link to reproduction - Issues with a link to complete (but minimal) reproduction code will be addressed faster
Verify canary release
Provide environment information
What browser are you using? (if relevant)
Firefox 107.0
How are you deploying your application? (if relevant)
Vercel
Describe the Bug
Dynamically importing with
next/dynamica Client Component that uses ause/clientdirective will cause anError: object is not a functionerror in development. The production build runs fine though.Also noticed that adding
ssr: falsewon't prevent the component from getting prerendered when runningnext build. Addingsuspense: trueorsuspense: falsewon't make a difference either.Expected Behavior
We should be able to dynamically import a component that makes heavy use of JavaScript in the client from a Server Component and use a custom Suspense-based fallback.
Link to reproduction - Issues with a link to complete (but minimal) reproduction code will be addressed faster
https://github.com/brvnonascimento/use-client-dynamic-bug
To Reproduce
yarn create next-app --experimental-app'use client'directivenext/dynamicto import the given componentError: object is not a functionin developmentScreen.Recording.2022-11-20.at.04.16.21.mov