Retiring vue-resource

Evan You
Evan You
Nov 3, 2016 · 2 min read

As Vue users, many of you may have used vue-resource for handling ajax requests in your Vue applications. For a long time it’s been thought of as the “official” ajax library for Vue, but today we are retiring it from official recommendation status.

Although listed under the vuejs organization, vue-resource was almost completely written and maintained by the PageKit team. We transferred it into the vuejs organization in the early days because it was great seeing the community contributing libraries solving an essential problem, and we greatly appreciate all the work the PageKit team has put into the project. However, over time we have come to the conclusion that an “official ajax library” is not really necessary for Vue because:

  1. Unlike routing and state-management, ajax is not a problem domain that requires deep integration with Vue core. A pure 3rd-party solution can solve the problem equally well in most cases.
  2. There are great 3rd party ajax libraries that solve the same problem, are more actively improved/maintained, and designed to be universal/isomorphic (works in both Node and Browsers, which is important for Vue 2.0 with its server-side rendering usage).
  3. Given (1) and (2), it’s obvious that we are duplicating the effort and bringing in unnecessary maintenance burdens by keeping vue-resource’s current status. The time we spend on resolving vue-resource issues can be better spent improving other parts of the stack.

Q&A

Does this mean vue-resource is deprecated?

No. It’s just no longer part of the “official recommendation”. The repo will be moved back to pagekit/vue-resource, and will continue to work. It will be up to the PageKit team to decide the long term plan for the library.

Should I Stop Using It?

It’s totally fine to keep using it if you are happy with it. Potential reasons to migrate away include maintenance, universal/isomorphic support and more advanced features.

What Should I Use Then?

You are free to pick whatever you prefer (even just $.ajax), but as a default recommendation — particularly for new users — we suggest taking a look at Axios. It’s currently one of the most popular HTTP client library and covers almost everything vue-resource provides with a very similar API. In addition, it is universal, supports cancellation, and has TypeScript definitions.

If you prefer something lower-level, you can simply use the standard fetch API. Take a look at isomorphic-fetch which is a polyfill that works in both browsers and Node.

Tips for Using Axios with Vue

  1. You need to provide your own Promise polyfill when using Axios, if your target environments do not natively support Promises.
  2. If you’d like to access this.$http like in vue-resource, you can just set Vue.prototype.$http = axios.

The Vue Point

The Official Vue.js Blog

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store