Book Image

Architecting Vue.js 3 Enterprise-Ready Web Applications

By : Solomon Eseme
Book Image

Architecting Vue.js 3 Enterprise-Ready Web Applications

By: Solomon Eseme

Overview of this book

Building enterprise-ready Vue.js apps entails following best practices for creating high-performance and scalable applications. Complete with step-by-step explanations and best practices outlined, this Vue.js book is a must-read for any developer who works with a large Vue.js codebase where performance and scalability are indispensable. Throughout this book, you’ll learn how to configure and set up Vue.js 3 and the composition API and use it to build real-world applications. You’ll develop the skills to create reusable components and scale performance in Vue.js 3 applications. As you progress, the book guides you in scaling performance with asynchronous lazy loading, image compression, code splitting, and tree shaking. Furthermore, you’ll see how to use the Restful API, Docker, GraphQL, and different types of testing to ensure that your Vue.js 3 application is scalable and maintainable. By the end of this book, you’ll be well-versed in best practices for implementing Restful API, Docker, GraphQL, and testing methods to build and deploy an enterprise-ready Vue.js 3 application of any scale.
Table of Contents (21 chapters)
1
Part 1: Getting Started with Vue.js
4
Part 2: Large-Scale Apps and Scaling Performance in Vue.js 3
9
Part 3: Vue.js 3 Enterprise Tools
11
Part 4: Testing Enterprise Vue.js 3 Apps
16
Part 5: Deploying Enterprise-ready Vue.js 3

Building your first Vue.js 3 app

Vue.js can be integrated into projects in multiple ways depending on the requirements because it is incrementally adaptable.

We will create a completely blank new Vue 3 project, or you can use the migration guide (https://v3.vuejs.org/guide/migration/migration-build.html#overview) to migrate your Vue 2 project to Vue to follow along.

In this section, we are going to cover how to build our Vue 3 application using the Vite command-line interface (CLI).

Creating a Vue 3 app with Vite

To create our first Vue 3 application, we will use the recommended Vite web development tool. Vite is a web development build tool that allows for lightning-fast code serving due to its native ES Module import approach.

In this book, we will be building an enterprise-ready Pinterest clone project, and all the backend data management of the project will be developed and hosted with Strapi.

Type along with these simple commands:

npm init @vitejs/app pinterest-app-clone
cd pinterest-app-clone
npm install
npm run dev
// If you're having issues with spaces in username, try using:
npx create-vite-app pinterest-app-clone

The preceding commands will create a pinterest-app-clone folder with Vue 3 installed and set up properly. Once done, open your favorite browser and access the web page with localhost:3000. This is what the web page will look like:

Figure 1.1 – A screenshot of the newly installed Vue 3

Figure 1.1 – A screenshot of the newly installed Vue 3

In this section, we explored Vue 3, the Composition API, and how to get started building your first application with Vue 3. In the next section, we will learn about the Strapi CMS that we will use for data and content management.

What is the Strapi CMS?

Strapi is an open source headless CMS based on Node.js that is used to develop and manage content or data using RESTful APIs and GraphQL.

With Strapi, we can scaffold our API faster and consume the content via APIs using any HTTP client or GraphQL-enabled frontend.

Scaffolding a Strapi project

Scaffolding a new Strapi project is very simple and works precisely like installing a new frontend framework. Follow these steps to scaffold a new Strapi project:

  1. Run either of the following commands and test them out in your default browser:
    npx create-strapi-app strapi-api --quickstart
    # OR
    yarn create strapi-app strapi-api --quickstart

The preceding command will scaffold a new Strapi project in the directory you specified.

  1. Next, run yarn build to build your app and, lastly, yarn develop to run the new project if it doesn’t start automatically.

The yarn develop command will open a new tab with a page to register your new admin of the system:

Figure 1.2 – The registration page

Figure 1.2 – The registration page

  1. Go ahead and fill out the form and click on the Submit button to create a new admin.

As we progress in this book, we will customize our Strapi backend instance to reflect Pinterest data modeling.