Hi. I am using Dialog from radix ui thats open based on the search params. I am experiencing hydration errors when I enter url localhost:3000?modal=login directly in the browser and I guess its because of prerendering - the dialog on the server did not render and on the client when nextjs was hydrating it did render.
I came up with two solutions but I am not sure which is better.
- Create smth like useClient hook like in nextjs docs
const [isClient, setIsClient] = useState(false);
useEffect(() => {
setIsClient(true);
}, []);
return (
<Dialog
open={isClient && params.get('modal') === 'login'}
- Import login modal using
dynamicwithssr: false