score:1

if (typeof document !== 'undefined') {
  // Do your document thing here
} else {
  console.log("We're on server")
}

Related Query

More Query from same tag