-
Notifications
You must be signed in to change notification settings - Fork 41
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
Use with Nuxt.js / SSR ? #19
Comments
|
I tried this approach but still get: |
@danchristian this is NOT SSR. This approach completely removes all contents from server-side-render, and leaves rendering to client. It means no performance advantages and no crawler would be able to read site data |
As a workaround for SSR, you might want to duplicate the data in a hidden div. |
In your gallery.vue use |
Thanks, This was perfect. |
I don't get this error when using The server mismatch you're getting is likely due to a misconfiguration in your Nuxt app. I posted my Nuxt configuration below which works perfectly, make sure in the nuxt.config.js the plugin has the I feel that this is getting a bit off topic and the issue should probably be closed if it can be stated why this issue is not a vue-masonry-css issue but more of an issue loading it in a different framework than just plain Vue. I am under the impression that the masonry component itself works fine with Nuxt apps as a client-only plug-in.
|
@ikluhsman what do you mean by misconfiguration? When you put something client only that means that on initial render you most definitely creating a hydration issues, because your client VDOM is different from SSR DOM, it's just how Nuxt works. |
In the meanwhile, you can rely on https://github.com/ymmooot/nuxt-jsonld to keep using SEO features on SSR. |
@the94air how is it related to what we discuss here? |
@AndrewBogdanovTSS I thought that's what everyone is trying to deal with, not being able to show the data to crawlers due to no SSR support 🥴 |
No, it's not an issue here. The problem is that component doesn't work at all if not used as client-only and even if used - it creates hydration issues that can lead to a complete page brake down where component is used |
Yes you are correct. My comment about misconfiguration was a bias from an unrelated issue causing problems in the last SSR app I was working on. Nonetheless, it seems to work on static generated pages without SSR, but again like you said, client-only is not the issue at hand. My apologies for the unhelpful comments. If I am able to assist the problem in my SSR apps I'll report back. |
The reason that causes SSR issue here is the fact that different number of columns are used on different resolutions. Since in SSR mode there is no bulletproof way to detect screen resolution of the user device mobile brakepoint is loaded by default but once client side kicks in number of columns is changed which creates hydration issue. Possible solution would be detecting user agent on the server, this could give at least approximate result which is enough in 99% of the cases. @ikluhsman the fact that you might not had this issue is probably because you always used same amount of columns for each resolution |
Hello, I am trying to find a masonry layout package that works with SSR. Can someone update me on whether this library works in Nuxt's SSR mode? If not, anyone have other suggestions. I checked out vue-masonry-wall but that one doesn't seem to work with SSR any longer. Thanks. |
@dosstx if you will find one - let me know. I guess in the future we could write a wrapper solution around this library that would detect support for |
@AndrewBogdanovTSS Thanks for the update, Andrew! The only thing I've been able to do is use Bootstrap and then write some logic to chunk the fetched data array into 3 columns. This gives me a masonry layout that works even with SSR (see concept screenshot below -- this is also what it looks like with JavaScript turned off). The cards are also rendered horizontally which is good for a natural left-to-right scan (latest cards are first and older cards are last). Unfortunately, two problems with this approach: 1.) If you plan to dynamically sort the cards (ie, 2.) In mobile/single column breakpoint, the ordering is not chronological. Though, for this, I think we can use client hints and fetch accordingly...though I haven't tried that yet. |
@dosstx the main problem with SSR in my use case was a responsive behavior. Since we can't reliably detect screen dimensions during SSR a fallback to mobile layout is done which creates hydration issues on desktop due to different amount of columns per brakepoint. |
Just found this ported version of vue-masonry-wall. It works for me...even with SSR! https://vue2-masonry-wall.yeger.eu/ And my sandbox: https://codesandbox.io/s/yeger-masonry-vue2-v03xv?file=/pages/index.vue No hydration issues, either. |
@dosstx thanks, I will try that |
Has anyone tried using this with Nuxt.js? I'm trying to use it as a plugin but get the following message:
The text was updated successfully, but these errors were encountered: