There are many topics and SO questions. but I don't find the best solution to detect mobile device.
I have two components. the first component is only for desktop, the second component is only mobiles.
{isMobile?
(<SecondComponent />)
:
(<FirstComponent />)
}
most solutions used getInitialProps function. but the Nextjs says:
Recommended: getStaticProps or getServerSideProps.