PhoneGap Apps with Vue.js? Yes please

January 10, 2017By 5 Comments

vue-logo

Vue.js

You’ve probably heard some buzz lately around Vue.js as one of the frameworks to check out in 2017. Vue.js has actually been around since 2014, but seems to be growing in popularity since Vue 2.0 was released last year. The Vue GitHub page has an impressive number of stars and describes Vue.js overall as:

A progressive, incrementally-adoptable JavaScript framework for building UI on the web.

Features

At its core, Vue.js is classified as a reactive, component-oriented view layer that is easy to integrate with other libraries and existing projects that can also scale in combination with supporting libraries to power sophisticated Single Page Applications. For instance there’s an official router, state management system (Flux/Redux type library), AJAX helpers, pre-built UI components, form validation and numerous other helper libraries you can take advantage of, making it “incrementally adoptable” overall. Another core feature to note is the reactive two-way data binding system which ensures your data and the DOM are always in sync.

What makes this framework an interesting choice to look at for mobile in particular is the minimal size (17kb for the core runtime and only 26kb for the runtime+vue-router+vuex), as well as the fact that the rendering layer was rewritten using a lightweight Virtual DOM implementation in Vue 2.0, greatly increasing performance. There are some interesting points and metrics regarding performance in comparison to some other popular frameworks in this post by the author, Evan You you may want to check out as well.

You can start learning Vue.js by using their guides here and JSFiddle sample app. There’s also a vue-cli available to help you scaffold your projects quickly. If you’d like to read more about how Vue.js compares with other frameworks in general, check out this guide posted on that topic specifically.

Mobile UI Frameworks + Vue.js

f7-logo

Framework7

Framework7 is an open-source UI framework for building hybrid apps that provides a heap of UI components, view navigation and other useful widgets to help you build mobile apps quickly. It also has support for both iOS and Android Material design. Take a moment to check out this overview post I wrote over on the PhoneGap blog to get a quick rundown of what it has to offer. I also recommend trying out their Kitchen Sink demo to see all of the components that come out of the box.

Vue Support

Recently Framework7 released a Framework-Vue plugin with support for pretty much all of the components and elements Framework7 supports, as well as integration of the Framework7 Router to render pages in the “Vue” way. This makes it super easy to take advantage of the best of both of these frameworks when building your mobile apps. If you were already using Framework7, you may also want to know there are some extra benefits to using this Framework7-Vue plugin in terms of more structured content, automatic data-binding and simplified layout differences for iOS and Material themes.

Along with their new support for Vue is a set of accompanying guides and sample templates you can use to get started developing quickly. The templates include a static version, a Webpack version and a Browserify version (the second two also with support for hot reload). Timo Ernst is a frequent Framework7 blogger that also posted a sample template and associated video on getting started with Framework7, Vue.js and Webpack that you should also check out.

Live Sample

Below is a live version of the Framework7+Vue Static Template to try out:

PhoneGap+Framework7+Vue Template

In an effort to make things easier to try out this new support immediately with PhoneGap, I decided to take the Framework7+Vue static template from above and add some necessary parts to it (cordova.js, deviceready handling etc) so you can use it directly with the PhoneGap/Cordova CLI. The resulting template is here in my GitHub repo. All you need to do is specify my URL as the template to use when creating your project from (as shown below) and you’re good to go.

    $ phonegap create myVueApp --template https://github.com/hollyschinsky/phonegap-template-framework7-vue
    $ cd myVueApp
    $ phonegap serve
If you’re using the Cordova CLI, simply swap out the phonegap command for cordova above. Further instructions are located in the project README.

onsen-logo

Onsen UI

Onsen UI is another UI framework available for building hybrid apps. It’s built on top of Web Components and it’s flexible in that it allows you to use it with various JS frameworks including Angular 1 & 2, React, Vue, Meteor, or independent of a framework. It also has support for iOS and Android Material design with automatic styling based on the platform. Check out their kitchen sink apps for Angular 2 and React to get a better idea of what they have to offer.

Vue Support

Onsen UI currently has support for Vue in a preview version of a binding library you can try out that contains a set of components extended to work with Vue, however it’s currently dependent on Vue 1.x. Support for Vue 2 is in progress however and expected to be coming in the very near future. If you’re interested in trying out their current support, take a look at this blog post containing some important details.


Useful Resources

Filed in: CordovaMobile DevelopmentPhoneGapPhoneGap 3.0UncategorizedVue.js

About the Author ()

Comments (5)

Trackback URL | Comments RSS Feed

  1. Steve says:

    Hi! How does this compare to Ionic 2.0, which incorporates Angular 2? Thanks

  2. RLa says:

    One month ago I built a desktop app with Vue.js 2 and Electron. This was my first project using Vue. It works very well with Electron so I guess it works well with PhoneGap too.

    For the UI we just used plain HTML/CSS + Font Awesome. The “browser” environment is fixed and there is not much need for traditional frameworks to iron out incompatibilities. In my opinion, the UI does not have to be pixel-perfect with regards to native controls. General usability and user experience matters more.

  3. Hi, please consider Quasar Framework too. http://quasar-framework.org/

  4. Javier says:

    Hi Holly, you forgot to mention http://quasar-framework.org/

    BR

  5. Darren says:

    Hi Holly

    Nice article and timely too.

    I also think you should take a look at Quasar Framework ( http://quasar-framework.org/ ).

    Amazing amount of work by largely one guy. Will some support I can see this being the Ionic of Vue.

    Be interested in your thoughts

    Thanks
    Darren

Leave a Reply