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

Vue+Meteor SSR calling the client-side component lifecycle hooks beforeMount() and mounted() on the server-side #409

Open
mrauhu opened this issue Jul 18, 2020 · 3 comments · May be fixed by #414
Labels

Comments

@mrauhu
Copy link

mrauhu commented Jul 18, 2020

Greetings, @Akryum.

Problem

Vue+Meteor SSR calling the client-side component lifecycle hooks on the server-side:

  • beforeMount();
  • mounted().

This results in breaking other packages from the Vue ecosystem, as example:

How to reproduce

  1. Clone the repo:
    git clone https://github.com/mrauhu/meteor-ssr-vue-meta
    cd meteor-ssr-vue-meta
    
  2. Run Meteor:
    meteor
    

Best wishes,
Sergey.

@welkinwong
Copy link

same

@ismail9k
Copy link

ismail9k commented Oct 4, 2020

Any updates regarding this issue?

@ismail9k
Copy link

ismail9k commented Oct 16, 2020

I've managed to fix this issue in my own project. The main idea is to prevent the Vue instance from mounting on the server, by removing the el property from the Vue object on the server-side, then mount the Vue instance manually client side

/client/app.js

import Vue from 'vue';

// Meteor Tracker integration
import VueMeteorTracker from 'vue-meteor-tracker'
Vue.use(VueMeteorTracker)

import App from './ui/App.vue'
import router from './router'

function createApp () {
  return {
    app: new Vue({
      // el: '#app', <= REMOVE THIS
      router,
      ...App,
    }),
    router,
  }
}

export default createApp;

/client/startup/index.js

import { Meteor } from 'meteor/meteor'
import CreateApp from './app'

Meteor.startup(() => {
  CreateApp().app.$mount('#app');
})

You can test this on my vue-meteor-boilerplate

ismail9k pushed a commit to ismail9k/vue-meteor that referenced this issue Oct 16, 2020
To overcome the vue-ssr and vue-meta issues (closes meteor-vue#409)
@ismail9k ismail9k linked a pull request Oct 16, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants