Skip to content

Server action in 18.2.6 vs 18.2.8 is not longer able to import server action in client component #69818

@pawanrana1992

Description

@pawanrana1992

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/A

Which 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

  1. create a project with nextjs 18.2.8 version
  2. create file which will use server actions with "use server" as required
  3. Add any 2 server actions and export as object = ( export const abcAction and efgAction) with full action api return logic and data handeling
  4. Create a client side component "use client"
  5. Import the action in the client component
  6. run the app

You will see the error

Change the nextjs version to 18.2.6

  1. create a project with nextjs 18.2.6 version
  2. create file which will use server actions with "use server" as required
  3. Add any 2 server actions and export as object = ( export const abcAction and efgAction) with full action api return logic and data handeling
  4. Create a client side component "use client"
  5. Import the action in the client component
  6. run the app => It will work without any error

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions