A Next.js component is marked async but it runs as a Client Component
async/await is not yet supported in Client ComponentsShort 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.
Fix it fast
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 components2Match what you see, then jump to its fix
- 1
The 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
The 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
The 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
The 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
- 1
What does the error look like?
async/await is not yet supported in Client ComponentsClient 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.tsx2Fix
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 devConfirmed by nextjs.org
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/*.tsx2Fix
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 buildConfirmed by nextjs.org
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.tsx2Fix
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 buildConfirmed by nextjs.org
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 components2Fix
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 devConfirmed by nextjs.org
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:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- TaskvareA task and project-management suite: React on the web, Flutter on mobile, TypeScript underneath.
Related fixes
Web apps
ESLint says an element in a list is missing its key prop
react/jsx-key
react/jsx-key fires when an element returned from map, Array.from or an array literal has no key.
3 causes, each with a fixWeb apps
There is no tailwind.config.js after installing Tailwind 4 and HeroUI in Next.js
HeroUI components render unstyled
Nothing is broken: Tailwind CSS 4 is configured in CSS and no longer creates tailwind.config.js.
3 causes, each with a fixWeb apps
react-i18next shows the wrong plural form for a count, or prints the key instead of the text
t('item') prints the key item instead of a translated sentence
i18next picks a plural from the count option and looks for keys ending in _one, _other and so on.
4 causes, each with a fixWeb apps
useSession throws because there is no SessionProvider above it
[next-auth]: `useSession` must be wrapped in a <SessionProvider />
useSession reads the session from React Context, and SessionProvider is what creates that context.
3 causes, each with a fixWeb 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 fixWeb 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