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

816 B

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

Arguments

None

Return type

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

Example code

import {isServer} from '@shopify/hydrogen';

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

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