Skip to content

Instantly share code, notes, and snippets.

@ryanmorr
Created January 15, 2024 07:03
Show Gist options
  • Save ryanmorr/aa3a33eedd7a97905b28d09d87ce41a3 to your computer and use it in GitHub Desktop.
Save ryanmorr/aa3a33eedd7a97905b28d09d87ce41a3 to your computer and use it in GitHub Desktop.
Are we on the client or the server?
function isBrowser() {
return typeof window != 'undefined' && typeof window.document != 'undefined';
}
function isServer() {
return typeof process != 'undefined' && {}.toString.call(process) == '[object process]';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment