useClient
A solution to fix the hydration error in Next.js.
Return Values
a boolean
value ensure that the component renders on the client side.
Example Usage
tsx
import { useClient } from 'react-pre-hooks';
export default function Example() {
const isClient = useClient();
return <h1>{isClient ? 'This is never prerendered' : 'Prerendered'}</h1>;
}
import { useClient } from 'react-pre-hooks';
export default function Example() {
const isClient = useClient();
return <h1>{isClient ? 'This is never prerendered' : 'Prerendered'}</h1>;
}