引用 : https://maku.blog/p/m7is4dn/
windowオブジェクトはクライアント(WEBブラウザ)で動作している時のみ存在するのでこれを調べると言う方法です
const isClient = () => typeof window !== 'undefined'
// const isServer = () => typeof window === 'undefined'
const HelloPage: FC = () => {
if (isClient()) {
console.log('これはクライアントサイド JS として実行されているよ!')
console.log(window.location)
alert('だから alert も使えるよ!')
}
return <h1>Hello</h1>
}