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

SSR compatibility #243

Closed
joshbotnet opened this issue Dec 22, 2016 · 46 comments
Closed

SSR compatibility #243

joshbotnet opened this issue Dec 22, 2016 · 46 comments

Comments

@joshbotnet
Copy link

joshbotnet commented Dec 22, 2016

Hey @marcosmoura and team, I'm integrating Vue Material with Nuxt (which uses SSR) as per their plugins instructions and get [Vue warn]: The client-side rendered virtual DOM tree is not matching server-rendered content. so I created an issue over there if you want to have a look - might be good for both projects - nuxt/nuxt#76

@joshbotnet joshbotnet changed the title Nuxt integration SSR compatibility Dec 22, 2016
@joshbotnet
Copy link
Author

Apparently Vue Material could be updated to work with SSR

@marcosmoura
Copy link
Member

This will be developed for the next version. Also I would love to see a PR with this fix. :D

@stbaer
Copy link

stbaer commented Jan 8, 2017

@marcosmoura - why is it not working with ssr? Some info and I may attempt a pull request. Been trying to use it with nuxt.js but debugging from there is somewhat hard.

@marcosmoura
Copy link
Member

marcosmoura commented Jan 8, 2017

Well. Right now the API rely on "window" and "document" to be rendered. I will need to change every single component to make it work.

@marcosmoura marcosmoura modified the milestones: v0.6.0, v0.7.0 Jan 10, 2017
@ram-you
Copy link

ram-you commented Jan 11, 2017

@marcosmoura
We are moving forward in our project based on "vue-hackernews-2.0". We want to integrate "Vue Material" but with the SSR rendering problem we can not use it. We hoped the solution with version 0.6 but now it is postponed to 0.7.
We praise the huge quantity and quality of your work and hope that the solution will not exceed 0.7.
Thank you very much.

@marcosmoura
Copy link
Member

Hi @ram-you

The only problem with the SSR solution, to be developed, is the large amount of testing and adaptations to the codebase. That's why I postponed it, because I already had a lot of features ready to be released and the SSR feature was holding them. I will try to prioritize this to be on 0.7.0.

@ram-you
Copy link

ram-you commented Jan 11, 2017

Thank you Marcos. I am confident that this will attract many more users. Because most of those who have migrated to Vue.js is mainly for server-side rendering. Thank you again and good luck.

@marcosmoura marcosmoura modified the milestones: v0.7.0, v0.8.0 Jan 16, 2017
@shelakel
Copy link

Hi @marcosmoura,

Out of curiosity I checked out this repo to get an idea of what would be involved in making it SSR compatible.

Besides the document and window global variables being undefined, the following 2 dependencies are not SSR compatible:

  • element.scrollintoviewifneeded-polyfill imported by mdMenuItem.vue
  • vue-style-loader

I reckon the cleanest approach would be to split server and browser builds and shim window methods such as setTimeout in the render path to execute without a delay for SSR.

@dohomi
Copy link

dohomi commented Jan 30, 2017

One thing to mention here as I saw this in another issue on NUXT. The upcoming Vue 2.2 release will offer server and client support for vue-style-loader. Here is the reference where I found it: nuxt/nuxt#12 (comment)

@marcosmoura
Copy link
Member

Yeah. There is some points that should be fixed in order to make the SSR support to work.

@u12206050
Copy link

Looking forward to the release of this feature. Finished an entire project after switching from Angular 2 thinking that everything is already in place for SSR, but am just waiting now for ssr in vue-material. Nice work on the components though, I must say it was very intuitive to use.

Just thought I would also share a workaround fix that we used on another component to get ssr working, since the component is mostly for animating when a user does a certain event, there was no need to really render it besides its' data on SSR, and thus we just by past the code that used window. Since most of vue-material is also mostly just modifying what is where and how, could it be a simple fix to by pass anything that any ways won't matter on the server? For example scroll events, since no scrolling is taking place on the server anyways.

@jevojipi
Copy link

Hello. Any news on that matter? Also trying to get it work with NUXT. Both are GREAT projects, would be happy if they play well together.

@roslaneshellanoo
Copy link

+1 for compatibility with nuxt

@cawa-93
Copy link

cawa-93 commented Mar 9, 2017

Just inform about the current situation. I try use it today and get this error:

Vue.js error

ReferenceError: document is not defined
    at Object.defineProperty.value (D:\Develop\fb-scaner\node_modules\vue-material\dist\vue-material.js:9:11279)
    at e (D:\Develop\fb-scaner\node_modules\vue-material\dist\vue-material.js:6:369)
    at Object.<anonymous> (D:\Develop\fb-scaner\node_modules\vue-material\dist\vue-material.js:10:18827)
    at e (D:\Develop\fb-scaner\node_modules\vue-material\dist\vue-material.js:6:369)
    at Object.t.__esModule.default (D:\Develop\fb-scaner\node_modules\vue-material\dist\vue-material.js:7:5309)
    at e (D:\Develop\fb-scaner\node_modules\vue-material\dist\vue-material.js:6:369)
    at Object.o (D:\Develop\fb-scaner\node_modules\vue-material\dist\vue-material.js:7:386)
    at e (D:\Develop\fb-scaner\node_modules\vue-material\dist\vue-material.js:6:369)
    at Object.<anonymous> (D:\Develop\fb-scaner\node_modules\vue-material\dist\vue-material.js:11:14365)
    at e (D:\Develop\fb-scaner\node_modules\vue-material\dist\vue-material.js:6:369)

I already dream about the release of version 0.8 and the support of the SSR

@sebastianmacias
Copy link

I'm in the same position. I'm starting a new nuxt.js project and I'm going to have to use vuetifyjs instead of vue-material due to the lack of SSR support

@nahtnam
Copy link

nahtnam commented Mar 18, 2017

Same here, have to chose vuetify over vue material due to lack of ssr

@drozdzynski
Copy link

I have nuxt.js and use vue-material with this code (nuxt plugin):

import Vue from 'vue'

if (process.BROWSER_BUILD) {
  var VueMaterial = require('vue-material')
  Vue.use(VueMaterial.MdCore)
}

But waiting for SSR 👍

@kodekoder
Copy link

@drozdzynski this code is not working. How did you set this up?

@drozdzynski
Copy link

@jerakode I wrote it in march, so now this is able to not work, I stop working with this library, so I don't know how to make it work now.

@kodekoder
Copy link

@drozdzynski cool, ok. Any advice what framework works nice with Nuxt, beside Vuetify? I am so struggling right now with that.

@sebastianmacias
Copy link

@jerakode what's wrong with Vuetify?

@ram-you
Copy link

ram-you commented Jun 14, 2017

@sebastianmacias
Vuetfy.js seems to be very promising but it is still in "Pre-release" phase and it still lacks a lot of functionality so not yet "Production ready".

@dohomi
Copy link

dohomi commented Jun 14, 2017

@ram-you same as vue-material all current implementation of material design didn't reach 1.0 yet. There are a couple of libraries out but in my opinion - if SSR is required - use vuetify. The gitter channel is very active @jerakode. I don't want to highjack this conversation just want to give my personal opinion. I was using vue-material in the beginning but due to the use of NUXT I had to replace it - couldn't set it straight with client-server hydration

@kodekoder
Copy link

kodekoder commented Jun 14, 2017

@sebastianmacias I don't need 600kb of Vuetify just to use 2-3 component. It's too opinionated. I have my own base, I just need few interactive UI elements. I tried to integrate mdc, but it's so stupidly build, so I drop it.

@kodekoder
Copy link

@dohomi so, basicaly, vue-material is not working fine with Nuxt, right?

@dohomi
Copy link

dohomi commented Jun 14, 2017

@jerakode please check the source: https://github.com/vuetifyjs/vuetify/blob/master/dist/vuetify.min.js
https://github.com/vuetifyjs/vuetify/blob/master/dist/vuetify.min.css
And this is before gzip. In my app the whole source with Vue Vuex Vuetify and some other vendor packages after gzip is roughly 110kb on NUXT
If you tried already vue-mdc maybe try muse-ui, in the release notes it states they support SSR

vue-material didn't do it for me, on any code-refresh the app crashed.

@kodekoder
Copy link

vue-mdc seems very early stage, I can't make it work at all. No docs, no help. I tried original mdc, but was able to load only CSS version.

muse-ui looks very nice, I forgot about it. Will try.

The blank original vuetify/nuxt starter weights over 700kb. When clean Nuxt starter in approx 150kb. Haven't tried gzip tho.

@Muscot
Copy link

Muscot commented Jun 25, 2017

I tried out a solution, that seems to work. I'm not sure if it's good or a bad :-) , what do you think?

My vue-material nuxt plugin:

if (!process.BROWSER_BUILD) {
const jsdom = require('jsdom')
const { JSDOM } = jsdom
const dom = new JSDOM(``)
global.window = dom.window
global.document = dom.window.document
global.Element = dom.window.Element
}

var Vue = require('vue')
var VueMaterial = require('vue-material')
Vue.use(VueMaterial)

@felipekm
Copy link

felipekm commented Oct 11, 2017

Hey @marcosmoura, any plans to release it?
I see a lot of devs moving to vuetify becase of this case.

@marcosmoura
Copy link
Member

Yep. I know. The new version is coming. With SSR Support. Finally!

@ram-you
Copy link

ram-you commented Oct 11, 2017

@felipekm
Its a little late for me. I have already migrated all my existing projects and those that are under development towards Vuetify.
Because I prefer VueMaterial spirit, perhaps, no I'm sure, it will be for future projects.

@felipekm
Copy link

Yeah @ram-you same feeling here, anyway I will wait for few days.
@marcosmoura let us know if any help is needed, let's make it happen.

@marcosmoura
Copy link
Member

marcosmoura commented Oct 11, 2017 via email

@hackuun
Copy link

hackuun commented Oct 11, 2017

@ram-you you forget to mention, that it could be late for you, but not the others.
@marcosmoura cool, will wait for updates. For some reason, I like vue-material better then vuetify 😄

@marcosmoura
Copy link
Member

@iamdubx Me too! :P

@ram-you
Copy link

ram-you commented Oct 12, 2017

@iamdubx of course for me. Never late for the community.

@sandeshdamkondwar
Copy link

Same here

@Samuell1
Copy link
Member

Enhanced SSR Support is in 1.0.0-beta5!

@marcosmoura marcosmoura removed this from the v0.8.0 milestone Nov 23, 2017
@christophwolff
Copy link

When i use a mdbutton with nuxt i get a document is not defined in my pages

@Samuell1
Copy link
Member

@christophwolff its weird because mdButton doesnt have any document in code

@Awais-cb
Copy link

Any update on this?

@christophwolff
Copy link

@Awais-cb Try to use it as a non SSR Nuxt plugin. Should work then.

https://nuxtjs.org/guide/plugins/#client-side-only

@Awais-cb
Copy link

thanks for your response chris will try as you suggested i have just one more question to ask will it effect my site's ranking for seo?

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