Meteor-vue2-example-routing questions

I am struggling to understand the example of meteor-vue project found here:

In particular the line

render: h => h(AppLayout),

in the client/main.js file:

// App layout
import AppLayout from '/imports/ui/AppLayout.vue';

// App start
Meteor.startup(() => {
  // Start the router
  const router = routerFactory.create();
  new Vue({
    render: h => h(AppLayout),

What is h here?
Is it a function?
Where is it defined and what does it do?
I am guessing that injects the AppLayout vue component inside the root App component being created though this new Vue call but I do not understand the syntax, even after reading the vue docs on render functions. Could anyone clarifies this?

Another question is whether this way to integrate vue with meteor by creating the root app vue component by JavaScript code inside the Meteor.startup object is the only way that works.

Wouldn’t it be possible to simply add an App.vue component in the template/imports/ui/ folder that would look something like:

<template name=“app”>

  app = new Vue({
    el: 'app';

Or must the code creating the app root instance with the router injected in it must necessarily appear in a Meteor.startup call to link the Vue code to the Meteor code?

I found answer to the first question here:
In short, this mysterious h is an alias for the createElement Vue function that creates a new node in the DOM. It apparently is an compulsory argument to the render lambda that the render option of a Vue instance is expected as value (why it needs to be passed as argument instead of just called inside the render lambda I still don’t get it)

h => h(AppLayout)
is just an abbrevation for
createElement => createElement(AppLayout)

Now if you want to stay at the highest possible level of abstraction and hence would like to avoid using render functions, you can substitute

new Vue({
    render: h => h(AppLayout),


new Vue({
    el: 'app',
    template: ''<app/>",
    components: { AppLayout }

BUT, this will only work if you import the development versions of Vue and VueRouter that include the template compiler instead of the production versions that exclude it and thus require the use of a render function.

Hence your imports:

import Vue from 'vue’
import VueRouter from ‘vue-router’

must be replaced by:

import Vue from '/node_modules/vue/dist/vue.common.js’
import VueRouter from ‘/node_modules/vue-router/dist/vue-router.common.js’
1 Like

Great you found the answer @Jacques and thank you for sharing it!

For the sake of completeness I’ll link an article from Sarah Drasner about this:

She mentions the Vue Guide and particularly this section: where it explains the createElement's arguments.

Also, maybe best to stick to using the versions that don’t ship the compiler along the rest of the code?