You want to conditionally render components on the server side based on the device type (mobile, tablet, desktop). The goal is to avoid rendering all components server-side and hiding them with CSS, and to prevent client-side JavaScript from causing a flash of content as it loads.
Create a hook that determines the device type based on window size and stores it in a cookie. Use this context to conditionally render components according to the device type.