Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combining Server-Side Rendering and Responsive Design #43

Open
anton-karlovskiy opened this issue Feb 5, 2021 · 1 comment
Open

Combining Server-Side Rendering and Responsive Design #43

anton-karlovskiy opened this issue Feb 5, 2021 · 1 comment

Comments

@anton-karlovskiy
Copy link
Member

anton-karlovskiy commented Feb 5, 2021

@pi0 @danielroe cc @addyosmani

One of the pains I've experienced in SSR of Next.js is to realize responsive design without unnecessary DOM elements being rendered.
In this project, we have the same case.

Problems in universally rendered apps with conditional rendering in regard to the responsive layout

  • window.mediaQuery cannot be used since it's not available on server-side rendering and there would be a DOM tree mismatch issue.
  • Using CSS media query would result in rendering all of the elements regardless of whether they are used either on desktop or on mobile.

I think this article explains this well.

We managed to avoid rendering unnecessary DOM elements by using https://github.com/artsy/fresnel in the Next.js project.

@pi0 @danielroe Could you please suggest what to use in Nuxt.js? Thank you.

@danielroe
Copy link
Member

You could use this module: https://github.com/nuxt-community/device-module

Or render both components and selectively hydrate based on screen size on client side using https://github.com/maoberlehner/vue-lazy-hydration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants