Skip to content

use doesn't work in async Server Component #44778

Closed as not planned
Closed as not planned
@amannn

Description

@amannn

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

    Operating System:
      Platform: darwin
      Arch: x64
      Version: Darwin Kernel Version 22.2.0: Fri Nov 11 02:08:47 PST 2022; root:xnu-8792.61.2~4/RELEASE_X86_64
    Binaries:
      Node: 16.16.0
      npm: 8.11.0
      Yarn: 1.22.18
      pnpm: 7.1.7
    Relevant packages:
      next: 13.1.2-canary.4
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0

Which area(s) of Next.js are affected? (leave empty if unsure)

App directory (appDir: true)

Link to the code that reproduces this issue

https://github.com/amannn/nextjs-bug-use-server

To Reproduce

  1. Clone the repro
  2. Run npm run dev
  3. Access http://localhost:3000

Describe the Bug

If I make use of use in an async component, this throws:

Screenshot 2023-01-11 at 16 56 03

Expected Behavior

I understand that in an async component you'd typically use async/await. However for reusable library code that can be executed either on the server or the client side, it would be very helpful if use can be called in server code as well.

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue was opened via the bug report template.lockedstaleThe issue has not seen recent activity.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions