useIsClient

Custom hook that determines if the code is running on the client side (in the browser).

Inspired on:

Visual example

site title
domain.tld
We are in client side?: false

Code base

import { isClient } from "@/utils/is-client";

export function useIsClient() {
	return isClient();
}

Code example

<!-- javascript -->
<script lang="ts">
	import { useIsClient } from "@dimaslz/svelteuse";

	const isClient = useIsClient();
</script>

<!-- html -->
<div>
	We are in client side?: {isClient}
</div>