How do I detect I am on server vs client in Next.js

后端 未结 4 1599
予麋鹿
予麋鹿 2021-01-01 09:10

I am using a customer express server with Next.js. It\'s running within a container. I am doing an http request with isomorphic-fetch to get data for my render.

4条回答
  •  暖寄归人
    2021-01-01 09:40

    One additional note is that componentDidMount() is always called on the browser. I often load the initial data set (seo content in getInitialProps(), then load more in depth data in the componentDidMount() method.

提交回复
热议问题