-
Here's the given example on the doc section "Client components need to be wrapped in a boundary": 'use client'
export default function Page() {
return (
<Suspense>
<Client />
</Suspense>
)
}
function Client() {
const [foo, setFoo] = useQueryState('foo')
// ...
} Why is there a 'use client' on top of the file if bellow it says 'Keep page.tsx as a server component (no 'use client' directive)'? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Adding the |
Beta Was this translation helpful? Give feedback.
Adding the
'use client'
directive to the page.tsx file is the immediate fix to get things working if you are defining components that use client-side features (like nuqs or React hooks), but the steps below indicate the optimal approach to get better UX: separating server and client files (and moving client side code as low down the tree as possible to pre-render the outer shell).