Skip to content

Conversation

@ohjooyeong
Copy link

@ohjooyeong ohjooyeong commented Jul 11, 2025

The previous documentation stated that useId cannot be used in Server Components that are async functions.

However, as of React 19.1.0, useId now works correctly in async Server Components as well.

I have tested this behavior and confirmed that the caveat is no longer necessary.

This PR removes the outdated note to reflect the current behavior.

Tested with:

  • next: 15.3.5
  • react: 19.1.0
  • react-dom: 19.1.0
// app/page.jsx
import { useId } from "react";

export default async function Page() {
  const id = useId();
  return (
    <div>
      <label htmlFor={id}>Name:</label>
      <input id={id} type="text" />
      <p>Generated id: <code>{id}</code></p>
    </div>
  );
}

This async Server Component renders without any error and the generated id works as expected.

스크린샷 2025-07-11 오후 3 39 45

@facebook-github-bot
Copy link
Collaborator

Hi @ohjooyeong!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@github-actions
Copy link

Size changes

📦 Next.js Bundle Analysis for react-dev

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

@facebook-github-bot
Copy link
Collaborator

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@ohjooyeong ohjooyeong marked this pull request as draft July 11, 2025 06:37
@ohjooyeong ohjooyeong marked this pull request as ready for review July 11, 2025 06:38
@rickhanlonii
Copy link
Member

It doesn't work if you do this:

// app/page.jsx
import { useId } from "react";

export default async function Page() {
  await something();
  const id = useId();
  return (...);

The error is in the linter only I believe.

@rickhanlonii
Copy link
Member

cc @eps1lon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants