Vue, Meteor & Apollo

I’m looking for resources on the following:

``> Adding Vue 2.0 to an Meteor project with existing Blaze templates (living side by side) and communicate with Mongo via Tracker/Subscriptions/Minimongo (the same way Blaze does).

``> Adding Vue 2.0 to an existing Meteor project with existing Blaze templates (living side by side) and communicate with Mongo via Apollo.

``> Any libraries that will make my life with Meteor and Vue more pleasant

``> I use a lot of forms, so any libraries (like validation) that will help with Vue.

I’m looking for any help you can provide, from mentoring to articles and videos – regardless of paywalls.

Basically, I’m considering Vue instead of React for Meteor.

1 Like

Hi, take a look at these packages that will help you use Vue with Meteor.

2 Likes

Impressive software @akryum, thank you. I’ll review and try it out.

When using the Meteor/Blaze/Vue examples, are they using Vue 2.0? Can I use FlowrRouter or do I need vue-router?

The examples are using Vue 1, but you can safely use Vue 2 as well for most of the packages. I strongly recommend using vue-router (and the akryum:vue-router2 package) instead of FlowRouter.

1 Like

Thanks.

Looking at the example: https://github.com/Akryum/meteor-vue-blaze

The first steps are to run the following commands:

meteor add akryum:vue akryum:vue-compoent

I looked these (1) (2) up in Atmosphere and they both seem to point to the same repo unless I’m mistaken.

Also, how does one pull in Vue 2.0 over Vue 1.* using the example repo?

And is it possible to use FlowRouter and vue-router2 side by side, and if not, will vue-router2 work with Blaze?

By default, they will add vue 1.0 in your package;json when you launch your app.
To use Vue 2.0, simply install it:

npm install --save vue@^2.0.1
1 Like

Thanks @akryum, but if Vue doesn’t work with FlowRouter and Blaze doesn’t work with vue-router2, then how can we have both a Vue and Blaze project side by side?

You can wrap your Blaze templates inside a vue component with this package.
For example, add routes like this:

{ path: '/todos', component: { template: `<div v-blaze="'Todos'"></div>` } },

Wait, so in order to use a Blaze template with vue-router2 (if that’s what you’re saying) we must wrap it within a vue component?

So if I have a huge template full of sub templates in a html page, I instead create a js file and add the entire blaze template within it wrapped inside what looks to be a component – this component also looks to include a route? If this is the case, what about the helpers/events/ etc associated with the template, do anything special to them as well? Do you have an example somewhere of this scenario?

Also, does vue-router2 have options for a {{> yeild}} type call for different templates on a page? For example I’m using kadira:blaze-layout for routing layouts.

Maybe “include” was a better word than “wrap”. You use blaze like before, with templates and events, then you include them in Vue components with their name. You don’t have to move your code at all for that. There is an example project in the package readme.

The layout would be tricky to do in blaze while using Vue router, you should consider recreating it in a Vue component (you can still reuse some subtemplates if it makes sense with v-blaze inside the Vue layout).
Edit: the {{>yield}} equivalent in vue-router is <router-view></router-view>

This is why I’d like to run the router side-by-side for a while. I don’t want to have to rewrite my existing Blaze templates that depend on layouts (there’s more than a few). Is there any way to run them side-by-side so I don’t have to rewrite large portions of my application to try out Vue within my existing app?

Even if I decided to use Vue more extensively after testing, there’s no way I’m going to be able to rewrite everything all at once. I need a way to ease into this with having to rewrite large swaths of my application.

When learning something new, it’s hard to tackle everything at once. If you take things step-by-step, each problem in isolation, it’s much easier. Making me switch routers, on top of trying out Vue within my app, will make it much more complicated.

Help me find a really easy way to try out Vue in my existing Blaze app, in isolation, without disturbing too much around it.

You may have a look at this example that uses FlowRouter instead of vue-router (but that’s not ideal). It should be very similar with vue 2.x.

EDIT: The general concept is to use Dynamic components that change their type (for example Todos.vue, Admin.vue…) depending on the current route.

1 Like

Thanks @akryum, any chance of adding Vue 2.0 to this project? https://github.com/Akryum/kickstart-meteor-vue-huge-app

@akryum, have you given any thought to adding a Blaze 2.0 wrapper around Vue 2.0 or something similar?

These are a few discussions we’ve had over on the Blaze repo.

I’d like to try my hand at migrating from Blaze to Vue, but there seems to be limitations on a slower migration. If there was a easy transition method or some bridge that could help, maybe more would try out Vue.

This is quite interesting. :smile: Might have a look.

1 Like