Client logic in SSR

Learn how to use client-side methods in server-rendered code.

The methods exposed by the useCroct hook only run on the client. Calling one while the component renders on the server throws an error like the one below:

Call these methods from a useEffect hook or an event handler such as onClick or onChange, so they run after hydration.

For server-side operations, use the server functions from a loader or action instead: fetch content with fetchContent, evaluate queries with evaluate, and manage identity with identify and anonymize.