Book Image

Vue.js 3 Cookbook

By : Heitor Ramon Ribeiro
Book Image

Vue.js 3 Cookbook

By: Heitor Ramon Ribeiro

Overview of this book

Vue.js is a progressive web framework for building professional user interfaces for your web applications. With Vue.js 3, the frontend framework is reinforced with architectural enhancements, new base languages, new render processes, and separated core components. The book starts with recipes for implementing Vue.js 3’s new features in your web development projects and migrating your existing Vue.js apps to the latest version. You will get up and running with TypeScript with Vue.js and find succinct solutions to common challenges and pitfalls faced in implementing components, derivatives, and animation, through to building plugins, adding state management, routing, and developing complete single-page applications (SPAs). As you advance, you'll discover recipes to help you integrate Vue.js apps with Nuxt.js in order to add server-side rendering capabilities to your SPAs. You'll then learn about the Vue.js ecosystem by exploring modern frameworks such as Quasar, Nuxt.js, Vuex, and Vuetify in your web projects. Finally, the book provides you with solutions for packaging and deploying your Vue.js apps. By the end of this Vue.js book, you'll be able to identify and solve challenges faced in building Vue.js applications and be able to adopt the Vue.js framework for frontend web projects of any scale.
Table of Contents (13 chapters)
5
Fetching Data from the Web via HTTP Requests
6
Managing Routes with vue-router
7
Managing the Application State with Vuex
11
Directives, Plugins, SSR, and More
Vue

What this book covers

Chapter 1, Understanding Vue 3 and Creating Components, provides the reader with recipes on how to use the new Vue 3 APIs to create custom Vue components using Vue's exposed core API and the Composition API. This chapter also helps the reader along an initial upgrade path of a Vue 2 application to Vue 3.

Chapter 2, Introducing TypeScript and the Vue Ecosystem introduces the reader to the TypeScript superset and how to use it, starting with basic types, interfaces, and type annotations. The reader will become ready for the development of a Vue application with Vue CLI, TypeScript, and vue-class-component.

Chapter 3, Data Binding, Form Validations, Events, and Computed Properties, discusses the basic Vue developments and component concepts, including v-model, event listeners, computed properties, and for loops. The reader will be introduced to the Vuelidate plugin for form validation and how to use it on a Vue component, along with how to debug a Vue component with vue-devtools.

Chapter 4, Components, Mixins, and Functional Components, walks the reader through building components with different approaches, including custom slots for contents, validated props, functional components, and creating mixins for code reusability. It then introduces the reader to a set of different approaches for accessing child components' data, creating a dependency injection component and dynamic injected component, and how to lazy load a component.

Chapter 5, Fetching Data from the Web via HTTP Requests, shows the reader how to create a custom wrapper around the Fetch API for HTTP calls on JavaScript, how to use the wrapper in Vue, and how to implement custom asynchronous functions on Vue. The reader will also learn how to replace the Fetch API in the wrapper for axios, and how custom handlers can be implemented on axios.

Chapter 6, Managing Routes with vue-router, takes a look at Vue's routing plugin and how to use it on Vue to create routes for the pages of a Vue application. It introduces the process of managing router paths, dynamic paths with parameters on the router path, lazy loading the page component, creating middleware for authentication on the router, and using an alias and redirect.

Chapter 7, Managing the Application State with Vuex, explores the Vue state management plugin to help the reader understand how Vuex works and how it can be applied to their application. This chapter also provides the reader with recipes for creating Vuex modules, actions, mutations, and getters, and explores how to define the base state for the store.

Chapter 8, Animating Your Application with Transitions and CSS, explores the fundamentals of CSS animation and transitions by providing recipes for custom animations based only on CSS. These will be used with a Vue custom component to achieve a nice looking application and provide the best experience for the application's users.

Chapter 9, Creating Beautiful Applications Using UI Frameworks, take a look at popular UI frameworks. The reader will build a user registration form with Buefy, Vuetify, and Ant-Design with their design concept. The aim of the recipes in this chapter is to teach the reader how to create a good-looking application with a UI framework.

Chapter 10, Deploying an Application to Cloud Platforms, shows how to deploy a Vue application on custom third-party hosters such as Vercel, Netlify, and Google Firebase. Using the recipes in this chapter, the reader will learn how to automatically deploy their application with integrated repository hooks and auto-deploy functions.

Chapter 11, Pro League – Directives, Plugins, SSR, and More, explores advanced topics on Vue, including patterns, best practices, how to create plugins and directives, and how to use high-level frameworks such as Quasar and Nuxt.js to create applications.