Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

A Next.js component is marked async but it runs as a Client Component

Errorasync/await is not yet supported in Client Components

Short answer

React cannot run an async function as a Client Component. A component becomes a Client Component when its file starts with 'use client', or when a file with that directive imports it. Either remove the directive so the component stays on the server, or take the await out and fetch in a parent Server Component or in an effect.

  • Applies to Next.js 15, Next.js 16, React 19
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Find the component named in the error and look at the first line of its file. Then search for any file above it that carries the directive.

    head -n 3 app/dashboard/page.tsx
    grep -rln "use client" app components
  2. 2Match what you see, then jump to its fix

    1. 1The first line of the file is 'use client' and the function is declared async.The file has 'use client' but the component is asyncFix
    2. 2The same file uses useState, useEffect or onClick, so removing 'use client' causes a different error.The component needs state or events, so it must stay a Client ComponentFix
    3. 3The async component has no directive itself, but the error still names it.An async Server Component is imported from a file that has 'use client'Fix
    4. 4The request depends on browser-only state such as a typed value or the window size.The data really has to be fetched in the browserFix

What does the error look like?

  • async/await is not yet supported in Client Components
  • Client components cannot be async functions.

Cause 1 of 4

The file has 'use client' but the component is async

1Check

A Client Component cannot be an async function. If the component only reads data and has no state, no effects and no event handlers, it does not need the directive at all.

grep -n "use client\|async function\|export default async" app/dashboard/page.tsx

2Fix

Delete the 'use client' line so the component is a Server Component again, and keep the await in it.

// app/dashboard/page.tsx (no 'use client')
export default async function Page() {
  const res = await fetch('https://api.vercel.app/blog')
  const posts = await res.json()
  return <ul>{posts.map((p: { id: number; title: string }) => <li key={p.id}>{p.title}</li>)}</ul>
}

3Verify

Restart the dev server and open the route. The error overlay is gone and the list renders.

npm run dev

Confirmed by nextjs.org

Did this fix it?

Cause 2 of 4

The component needs state or events, so it must stay a Client Component

1Check

Split the file in two. The part that fetches stays on the server; the part that reacts to the user moves into a small Client Component that receives the data as props.

grep -n "useState\|useEffect\|onClick" app/dashboard/*.tsx

2Fix

Make the page an async Server Component that awaits the data, and pass the result to a Client Component. Props passed this way must be serializable.

// app/dashboard/page.tsx (Server Component)
import LikeButton from '@/app/ui/like-button'
export default async function Page() {
  const post = await getPost()
  return <LikeButton likes={post.likes} />
}

// app/ui/like-button.tsx
'use client'
export default function LikeButton({ likes }: { likes: number }) {
  // useState and onClick live here
  return <button>{likes}</button>
}

3Verify

The page loads and the button still responds to clicks.

npm run build

Confirmed by nextjs.org

Did this fix it?

Cause 3 of 4

An async Server Component is imported from a file that has 'use client'

1Check

Everything a 'use client' file imports joins the client bundle. An async component imported there turns into a Client Component. Server Components passed as children or other props are not pulled in that way.

grep -rn "import .*from" app/ui/modal.tsx

2Fix

Stop importing the async component inside the Client Component. Render it in a Server Component and pass it down as children.

// app/page.tsx (Server Component)
import Modal from './ui/modal'
import Cart from './ui/cart' // async Server Component
export default function Page() {
  return (
    <Modal>
      <Cart />
    </Modal>
  )
}

3Verify

Run the build and confirm the error no longer names the Cart component.

npm run build

Confirmed by nextjs.org

Did this fix it?

Cause 4 of 4

The data really has to be fetched in the browser

1Check

If the fetch cannot start on the server, a Client Component has to do it after it mounts.

grep -rn "window\.\|localStorage" app components

2Fix

Remove async from the component and fetch inside useEffect, or use a data library such as SWR or React Query. The docs prefer server-side fetching when that is possible.

'use client'
import { useState, useEffect } from 'react'

export function Posts() {
  const [posts, setPosts] = useState<{ id: number; title: string }[] | null>(null)
  useEffect(() => {
    async function load() {
      const res = await fetch('https://api.vercel.app/blog')
      setPosts(await res.json())
    }
    load()
  }, [])
  if (!posts) return <div>Loading...</div>
  return <ul>{posts.map((p) => <li key={p.id}>{p.title}</li>)}</ul>
}

3Verify

Open the page: the loading text shows first and the list appears after the request returns.

npm run dev

Confirmed by nextjs.org

Did this fix it?

How do I stop it coming back?

  • Add 'use client' only to the small file that needs state, effects or events; keep pages and layouts as Server Components.
  • Keep eslint-config-next enabled: it ships a rule that flags async Client Components before you run the page.
  • Fetch on the server by default and pass plain data down as props.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Web apps

next/link throws React.Children.only on its children

Error: React.Children.only expected to receive a single React element child.

React.Children.only accepts exactly one React element and throws for anything else, including an array with one item.

3 causes, each with a fix

Web apps

Hydration failed after adding next-themes dark mode

Console reports a server and client mismatch on the html element

next-themes changes the html element and knows the theme only in the browser, so server HTML and client HTML differ.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.