Showing posts with label vue development. Show all posts
Showing posts with label vue development. Show all posts

Tuesday, March 23, 2021

What’s New In Vuejs 3.0 ?


Vue is a progressively Javascript Framework to build UI and single page apps. It is an open-source Model-View-View Model (MVVM) framework. The core framework is basically focused on the view layer and it can be easily integrated with other libraries and projects too. Using modern tools and libraries, Single page apps can be easily handled. Vuejs 3.0 has been officially launched and planned to upgrade to Javascript framework which is used to build web user interfaces. Vuejs 3.0 is smaller, faster, more maintainable, equipped with better TypeScript support, and easier to target native. Let us see what’s new in Vuejs 3.0?

What’s New In Vuejs 3.0?

In the last few years, there has been changes in vuejs development. Also, the community has grown from a small upstart to a full-fledged SPA library. With this new version, the team has added few supports to augment the library, simplify coding on Vue and adopt modern techniques of web development. Let’s have a look at new features of Vuejs 3.0.

Features Of Vuejs 3.0-

1. Composition API-

It is one of the greatest features in Vuejs 3.0. It has added a set of function-based APIs called as Composition API. These APIs are added to address the issues in Vue 2. Composition API has was launched as a plugin however in Vuejs 3.0 it doesn’t have to be installed like a plug in like previous. Now, it is in-built into the package and can be used without any extra setup. One main reason of formulating Composition API is to improve quality of code by allowing decouple features of logic.

In vue 2 where developers depends on extending the object and then share logic, vue 3 enables the sharing feature through standard Javascript/Typescript patterns rather than inventing new. It helps to see the features as they were added. Also, the Composition API makes it easy for types to infer, which supports the typescript in a better way. Vue 3.0 allows the component building and new API toco-exist with options API, without replacing it. Composition API provides flexible code organization and logic reuse capabilities with other improvements. Codes are easy to ready and organized better when written with Composition API.

2. Multiple Root Elements(template syntax)-

In Vue 2, template tag can only take one root element. Though we had just two <p> tags, we had to enclose them within a <div> tag to work it. So, we had to change the CSS code and in the parent component so as to looked as expected. In Vue 3, this restriction is removed. Now, there is need for a root element. You can use any number of tags directly inside the <template></template> section:

<template>
  <p> Count: {{ count }} </p>
  <button @click="increment"> Increment </button>
  <button @click="decrement"> Decrement</button>
</template>

Equivalent code in Vue 2:

<template>
  <div class="counter">
    <p> Count: {{ count }} </p>
    <button @click="increment"> Increment </button>
    <button @click="decrement"> Decrement</button>
  </div>
</template>

3. Better Typescript Support-

With the new Composition API, the internal functions are used as expected in JavaScript which takes into consideration much better TypeScript support. This results in better type inference with bindings returned from setup with props declaration used to infer types. TypeScript definitions benefit JavaScript users largely, making the Component code by TypeScript and Javascript look identical. The typescript helps in upgrading the maintainability of the Vue codebase and makes it simpler for developers to contribute. It is a frequent choice for large projects due to its popularity. Vuejs 3 internals in TypeScript assists to benefit completely from Vue’s TypeScript with the standard code support available in modern IDEs like Visual Studio Code or WebStorm. Since TypeScript’s Vue code is 90% Javascript, javascript users benefit from code intelligence features with modern IDEs. 

4. Reactivity-

Vue 2 had great reactivity but there were some cases where Vue 2 fell short. Let’s revisit Vue 2 and see what those limitations were-

To show reactivity, we’ll use watchers to listen to one of the state variables and then change it to check whether the watchers are triggered: 

<template>
  <div class="hello" @click="test">test {{list }} {{ myObj }}</div>
</template>
<script>
export default {
  name: "HelloWorld",
  data() {
    return {
      list: [1, 2],
      myObj: { name: "John" }
    };
  },
  watch: {
    list: {
      handler: () => {
        console.log("watcher triggered");
      },
      deep: true
    }
  },
  methods: {
    test() {
      this.list[2] = 4;
      this.myObj.last = "HS";
      delete this.myObj.name;
    }
  }
};
</script>

None of the above three modifications —, for example, adding new item to an array based on the index, adding new item to an object, or removing an item from the object — is reactive in Vue-2. So, watchers won’t be triggered, or the DOM would be updated. We had to use the vue.set() or vue.delete() methods. In vue 3, these work directly without any helper functions:

export default {
  setup() {
    let list = ref([1, 2])
    let a = ref(0)
    let myObj = ref({ name: 'John' })
    function myFun() {
      list.value[3] = 3
      myObj.value.last = 'HS'
      delete myObj.value.name
    }
    return { myFun, list, myObj }
  }
}

We can see that watcher was triggered all four times in the Vue 3 setup.

5. Global Mounting-

When you open main.js in the about project, you can see that something is different. No longer we use the Global Vue instance to install plugins and other libraries. Rather, you can see createApp method:

import { createApp } from 'vue'
import App from './App.vue'
const myApp = createApp(App)
myApp.use(/* plugin name */)
myApp.use(/* plugin name */)
myApp.use(/* plugin name */)
myApp.mount('#app')

Benefit of this feature is that it protects the Vue app from third-party libraries/plugins we use that might override or make changes to the global instance- mostly by the use of Mixins. 

Now, with createApp method, we install those plugins on a specific instance and not the global object.

6. Portals-

This is a feature where we can render a part of code which is present in one component into another component in a different DOM tree. There was a third-party plugin called portal-vue that achieved this in Vue 2.

With Vuejs 3.0, portal is inbuilt and also it is easy to use. Vuejs 3.0 has a special tag called <Teleport> , and any code enclosed within this tag will be ready to teleported anywhere. The Teleport tag takes a to argument.

<Teleport to="#modal-layer">
  <div class="modal">
      hello
  </div>
</Teleport>

Any code inside <Portal></Portal> will be displayed in the target location mentioned.

<div id="modal-target"></div>

7. Multiple v-modes-

V-mode is a directive which is used for two-way binding on given component. Mostly it is used with form elements and custom components.

V- model from the form elements looks like-

<input v-model="property />

It can be modified from the inside of component by passing reactive property and listening  to input events. 

Let’s rewrite the above example to see how the syntax will affect-

<input
  v-bind:value="property"
 v-on:input="property = $event.target.value"
/>

V-model directive can help in syntactic sugar for two-way binding in our components. But you have only one v-model per component. This is the best feature of Vuejs 3.0 and it lets you to give v-model properties names without any restriction.

8. Suspense-

This feature helps in rendering a default component untill the main component fetches the data. The asynch operations which are used to fetch data from server are done by Suspense. It can be used in individual parts of template or complete template. This concept derived and adapted from the React ecosystem to suspend your component rendering.

Wrap up-

With the development of the Vue, the community has led to the enhancement of the framework. These are some of the impressive features of Vuejs 3.0. There can be few others too. If you are thinking to use Vue for your next project, know these amazing new features in Vue. In case of any difficulties regarding vue development, consult with Solace experts. We are here to help you through consultation and development with new features. You can also hire skilled Vue developers of Solace team on flexible basis. Connect with Solace and get a free quote for an effective vue development. We will be happy to help you. 



Wednesday, February 3, 2021

React Vs Vue: Which One To Choose In 2021?

 


These days web applications are ruling the development landscape and will continue in the future too. When it comes to choosing Javascript frameworks and libraries, developers came up with many options including React and Vue. The challenging part is deciding to use Vue or react for use  in your tech stack. Both use a Virtual DOM and possess a reactive and component-based structure. Here we will compare two very popular web app frameworks React and Vue on the basis of various parameters such as, user-experience, performance, testability, security, developer availability and so on. Before digging to the comparison, let us see each one in detail.

React-

React.js is an open-source javascript library used to build web apps with rich user interfaces. It offers flexibility to create reusable custom components that encourage rapid development processes. Also, it is user friendly due to its ability to allow quick rendering of a web page. This library promotes the development of light-weight and complex business applications.

One can create not only web apps with React.js, but also media sites, video streaming platforms, software as a service tools, mobile apps, desktop apps, progressive web apps, JAMstack sites etc. Paypal, BBC, Facebook, Netflix, Twitter are some of the examples of popular apps created with React.

Vue-

It is a lightweight and flexible JavaScript-based framework that provides advanced web tools to develop modernistic SPAs and front-end web apps. Vue is also considered a versatile and progressive JavaScript framework because it allows change creation in an application code without influencing any core feature built and this provides an opportunity to create progressive UI. With decoupling, Vue also offers opportunities to extend functionalities of web app with customized modules and visual components.

Know the advantages of reactjs for building interactive user interfaces at- 7 Advantages of ReactJS for Building Interactive User Interfaces.

One can create single-page apps, progressive web apps, small project apps, large scale enterprise apps, existing app design extension, existing app functionality extension with Vue. Behance, Gitlab, adobe portfolio, laravel spark, grammarly are some of the apps created with Vue.

React Vs Vue- A Comparison

1. Learning Curve-

React-

React adopts the JSX format, where HTML is written in JavaScript. Though JSX is inline with functional programming, developers are saddled with the responsibility of figuring out this new approach. React heavily depends on other third party components for effective use. This can be an issue for developers since they news to grasp a lot of information just to get things done. React has a good documentation.

Vue-

Vue is easy to learn as compared to React. It separates concerns so that web developers are already used to, decoupling HTML, CSS and JavaScript. Vue allows the use of JSX for those who want to adopt that style. It is easy to get accustomed with Vue because it picked out the good parts of React and Angular. So it is easy for developers from either of the two backgrounds to fit in perfectly. Vue has a well detailed documentation.

2. Performance-

React-

React app’s performance is faster, a lightweight performance in user experience with individual components working in a fine functional way. It’s component based architecture helps to build more robust single page apps, reusability removes code clutter and reduced DOM manipulation speeds up the page loading. This reflects seamless app performance and pleasing user experience. Library works on updating the necessary changes to the webpage without reloading the entire page. Hence it eliminates the unnecessary loading of page and rather refreshes the data. To build react apps by setting some programming practice, you can use minimal approach.

Vue-

When each new feature added or extension of a component, Vue app becomes more uncertain that makes it hard for the app to load faster. Whereas, this framework has a virtual DOM, that serves as the default tool which helps in app’s performance optimization. Lazy loading feature of Vue helps to improve load time. Vue deals with third-party library in an asynchronous way by automatically handling the critical dependencies by isolating the libraries into the ones that need to be included in the main application bundle and the ones that can be left in routes away from the core bundle. 

3. Architecture-

React-

It doesn’t have a built-in architecture pattern. React caters to the view layer of app which is made with components. React components work as functions that render the underlying user interface as data changes. Continuous interaction between the users’ actions and state of app components makes internal architecture of Recat.js. The state of the React component is excellent when you need to build applications with limited functionality and scope. React is dependent on external libraries such as Flux, MobX, Reflux, Redux for building real-world applications.

Vue-

It follows the ViewModel approach and supports the pattern on MVVM in case of developing large-scale apps. View part and Model part are connected in two-way binding.

Model- Functions like Model object of JavaScript. When the data object enters the Model part, the data instance is transformed into reactive elements to create appropriate storage layers discretely.

View- There is a management of DOM instances in the View part of Vue. It makes use of DOM-based templating to successfully creating root elements and correspond with required DOM components.

Viewmodel- It handles the synching necessity between Model and View part of code. This Object is the primary part to interact developers with code.

Architecture of Vue and its DOM structures are abstracted into parts- Filters and Directives. Vue is not a full-blown framework so it follows a View layer pattern, handling of app development is made simple and flexible.

4. Scalability-

React-

React apps are made up of pure javascript so developers can depend on traditional easy to organize the code to make projects more scalable. This is a good framework for building scalable UIs pertaining to the concept of virtual DOM and component reusability.

Vue-

Vue is preferred for developing small-time apps and not scalable apps regardless of its ability to extend app with its flexible tools. Scalability can be made possible by forking a vue app by breaking it into multiple multiple repositories to separate the app for convenient scaling as per requirement. As the architecture is little dynamic, scalability is achieved by using web packs and Mixin elements offered by Vue to override the code extending limitations.

5. Application Size-

React- 

It is a library and not a fully featured frontend framework like Angular. React’s app sizes are bigger as compared to other. Latest react versions have reduced bundle size by reducing app size by 30% to previous version.

Also know- Most Common Mistakes To Avoid In React Development.

Vue-

It is a lightweight framework and so its app size might not be heavy like other frameworks. A simple Vue app has a size of between 50kB to 100kB. Vue CLI might make the app size appear large when it loads the code for first time due, but implementing lazy loading components, codes can be broken into smaller parts and improve load time. Tools such as NuxtJS, Vuex, Bit, Vue-router eliminate the need of code writing from scratch with effective state management that predicts unnecessary functions, codes and eliminates them.

Know the reasons to choose VueJS for web app development at- Why You Should Choose VueJS For Web App Development?

6. Code Maintenance-

React-

We know that react has component based architecture and it concentrates on building UI components, custom functionalities in user interface and optimally using logic to build functionalities. While developing app with React, you are developing functional and individual code snippets. Those snippets are reusable to other apps and various modules of the app. Dividing app into specific parts helps to manage app efficiently. 

Vue-

Vue is ever-growing technology and is rising in pace against most frameworks that have existed for a long time. So maintaining a Vue app is not that much hard. Vue lacks good support, creating conventional coding practices help to overcome limitations and obstacles. Vue is future-proof considering its effortless integration abilities and code grafting continuity onto existing DOM and HTML mark-up with zero prerequisites.

When To Choose REACT?

  • You can choose react when you want to play around with many libraries, tools or ecosystems.
  • Prefer React to develop scalable apps without any hassle for testing and debugging.
  • Go with React to build complex app with better time-to-market.
  • You can build video streaming platforms and media sites effectively with React.

When To Choose VUE?

  • You can prefer Vue to build progressive web apps and single page apps.
  • Also, if you want to extend the functionality of existing apps, go with Vue.

Final Words-

The above comparison will surely help you to choose the best one between React and Vue. If you are still confused to choose the best one, consult with solace experts. We are here to help you through consultation and development with experts skilled in modern technologies. You can also hire react developers and Vue developers of Solace Team for an effective development. Connect with Solace and get a free quote for an effective web app development. We will be happy to help you.

Friday, December 27, 2019

Some cool Vue UI Component Libraries that will rule In 2020

Vue.js, is a popular JavaScript library that you can use to make dynamic applications on the front end. Since its modest beginnings in 2014, it has gained a leap in the recent two years. Vue has risen as the strong competitor to Angular and also React. Know the comparison of Angular vs React vs Vue at- Angular vs React vs Vue: A 2019 Comparison (Updated). One reason for Vue’s popularity is the wide use of components, which make development a lot simpler to grasp. A component in Vue, actually, refers to a single entity within the application.
Every component might be a graphical part of the application, with its unique view and behavior. Components allow the logical separation of each aspect of a Vue application. This helps with code reusability. Vue components also help in sharing over projects and teams, making the process of development more effective. Here we will go through most interesting Vue UI component libraries. Let us see one by one.

Vue UI Component Libraries for 2020-

1. Vuetify-

Vuetify is a framework over Vue. It allows you to create clean, semantic, reusable UI components. It works with Vue’s Server Side Rendering (SSR). Vuetify has a consistent update cycle, which allows you to fix bugs and enhancements more often. The development team is committed to provide you the best experience you desire. What makes Vuetify a fascinating choice among the best Vue UI component libraries is the accessibility of ready-made framework for code – as pre-made vue-cli templates. This helps you to start rapidly. Vuetify also has a good community and regular updates.

2. Vue Material Kit-

Vue Material Kit is a beautiful resource built over Vue Material and Vuejs. It is an alternate way that you can use to accelerate your design/development process when building new sites or web applications. Basic knowledge of JavaScript, Vuejs and Vue Router is required, but other than that, the package is really simple to grasp. There are 60 high quality components as a part of the kit, two customized plugins, and also three model pages.

3. Vux

Vux is a framework based on WeChat’s WeUI and webpack. It’s documentation’s most part is in Chinese, with a little bit English translation. Vux supports rapid development of mobile components for your application.

4. Buefy-

Buefy is a lightweight UI component library. It is based on Vue and Bulma, a CSS framework. This framework is packaged with Bulma and is under 100 KB. If you are convenient with SASS, you will feel comfortable with Buefy’s similarities with SASS. That being stated, while Buefy gives a readymade components to use for a beginner application, you may think that it’s not sufficient if dealing with a large project.

5. Keen-UI-

Keen UI, is a Vue UI component libraries having focus on interactivity through JavaScript instead of visual components. This component library is inspired by Google’s Material Design, and also accompanies a simple to use API. Keen UI doesn’t repeat the need to be used over your application. It has some helpful components that can be deliberately placed when required. Hence, Keen UI is a best decision while adding iterative features to existing application.

6. Element

This is a UI component library for the web that has versions for React and Angular, in addition to Vue. This component library has focus on desktop applications, as its components are not responsive. Element also has important documentation in Chinese, English and Spanish. 

7. VuePress-

VuePress is a static site generator. This framework uses webpack for creation of pre-rendered static HTML pages, which makes the processing extensively faster. The use of VuePress offers many possibilities for your project such as automating your documentation process. It is easy to incorporate into your existing application. A significant disadvantage is that SEO support is still new, and the documentation doesn’t concentrate on this point yet.

8. Mint-UI-

This is a lightweight Vue UI component library based on the Babel JavaScript compiler. The small size of this package makes it appropriate for use in mobile apps. This library has 13K stars on GitHub. Development with framework is still going on. 

9. Bootstrap-Vue-

Bootstrap-Vue brings the strength of Bootstrap. It is a widely used CSS library of Vue. It gives you readily available UI components and a grid system. Also everything is mobile first and responsive. Components of this library are compatible with the WAI- ARIA guidelines for web accessibility. It has strong community support. Documentation is also available for this library. Hence it is easy to use for beginners.

Which Vue UI component library you should choose?

These are some Vue UI component libraries that perform different functions. But which one is best? Again the answer is “it depends”. If you are looking for a plug- and- play solution for your projects, you can choose Vuetify or Keen-UI.
Are you confused to choose the best library? You can consult with Solace experts and get back with the appropriate solution according to the project requirement. Experts team is well proficient in new trends and technologies to give you the best solution. We will be happy to help you.