-
Notifications
You must be signed in to change notification settings - Fork 30.6k
Description
Verify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: win32
Arch: x64
Version: Windows 11 Pro
Available memory (MB): 32524
Available CPU cores: 32
Binaries:
Node: 20.14.0
npm: N/A
Yarn: N/A
pnpm: 9.4.0
Relevant Packages:
next: 14.2.8 // Latest available version is detected (14.2.8).
eslint-config-next: 14.2.8
react: 18.3.1
react-dom: 18.3.1
typescript: 5.5.4
Next.js Config:
output: N/AWhich example does this report relate to?
any fresh project
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
My project is running in 14.2.6 nextjs version and actions api working fine when importing into client component. But when updating to 14.2.8 version, I am getting import error
Error: Cannot access AuthTemplate.then on the server. You cannot dot into a client module from a server component. You can only pass the imported name through.
at Object.get (*\node_modules.pnpm\next@14.2.8_@babel+core@7.25.2_react-dom@18.3.1_react@18.3.1__react@18.3.1\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:12:125427) {
digest: '815452591'
}
I validate the Server action import with 18.2.8 version in client component using "use client" and in actions file "use server".
The same is working fine in 18.2.6 but not in 18.2.8 version.
and I have to revert my app to again 18.2.6 to work as expected.
Expected Behavior
The actions functions should import in client component smoothly without any error, as per documentations.
To Reproduce
- create a project with nextjs 18.2.8 version
- create file which will use server actions with "use server" as required
- Add any 2 server actions and export as object = ( export const abcAction and efgAction) with full action api return logic and data handeling
- Create a client side component "use client"
- Import the action in the client component
- run the app
You will see the error
Change the nextjs version to 18.2.6
- create a project with nextjs 18.2.6 version
- create file which will use server actions with "use server" as required
- Add any 2 server actions and export as object = ( export const abcAction and efgAction) with full action api return logic and data handeling
- Create a client side component "use client"
- Import the action in the client component
- run the app => It will work without any error