Client Component

Include the 'use client' directive at the top of page.js to indicate rendering at the client.

Client Components are useful for adding interactivity, event listeners, and browser APIs to your application.

In Next.js, Client Components are rendered differently based on whether the request is part of a full page load or a subsequent navigation.

Full Page Load:

Subsequent Navigations:

(Hydration is the process of making static HTML interactive by attaching event listeners, using the hydrateRoot React API.)

(Click the 'Preview' button at the bottom right to grant Geolocation permission.)
In client components, we can use standard React hooks and browser APIs. For example, we can use the useState() hook to manage the state of a component, and the useEffect() hook to perform side effects in a component. We can also use browser APIs such as the geolocation API to get the the visitor's physical location.