hydrogen/packages/hydrogen/src/utilities/isClient/README.md
2021-11-09 18:20:09 -08:00

821 B

The isClient utility is a function that returns a boolean indicating if the code was run on the client.

Arguments

None

Return type

A boolean indicating if the code was run on the client.

Example code

import {isClient} from '@shopify/hydrogen/client';

export function MyComponent() {
  if (isClient()) {
    return <p>I ran on the client</p>;
  }

  return <p>I ran on the server</p>;
}