NashTech Blog

Table of Contents

What is Quasar?

Quasar Framework is an open-source, Vue.js-based framework designed to help developers create high-performance, responsive web applications, mobile apps, and desktop applications using a single codebase. It is known for its versatility, extensive component library, and ease of use, making it a popular choice among developers.

Key Features

Cross-Platform Development: Quasar allows you to build applications for multiple platforms, including web, iOS, Android, and Electron for desktop. This means you can write your code once and deploy it everywhere, saving time and resources.

Rich UI Components: The framework comes with a comprehensive library of UI components that are customizable and responsive. These components are designed to follow Material Design guidelines, ensuring a modern and user-friendly interface.

Performance Optimization: Quasar is built with performance in mind. It includes features like tree-shaking, lazy loading, and code splitting, which help reduce the size of your application and improve load times.

Powerful CLI: The Quasar CLI (Command Line Interface) simplifies the development process. It provides commands for scaffolding new projects, running development servers, and building production-ready applications with ease.

Theming and Customization: Quasar supports theming, allowing developers to easily switch between different styles and customize the look and feel of their applications. You can create your own themes or use the built-in ones.

Extensive Documentation and Community Support: Quasar has thorough documentation that covers everything from installation to advanced features. Additionally, its active community provides support through forums and chat groups, making it easier to find help when needed.

Why Choose Quasar?

Efficiency: Quasar streamlines the development process by providing a unified framework for building applications across multiple platforms. This reduces the need for maintaining separate codebases and speeds up development time

Robust Ecosystem: With a rich set of plugins, extensions, and integrations, Quasar fits well into existing development workflows and enhances productivity

Active Development: Quasar is actively maintained and updated, ensuring that it stays current with the latest web technologies and best practices

Step-by-step guide to implementing a project with Quasar

Step 1: Prerequisites

Ensure you have the following installed:

  • Node.js (version 14 or newer)
  • NPM (version 6 or newer) or Yarn (classic) or PNPM (version 8 or newer)

Step 2: Install Quasar CLI

Open your terminal and run:

  • Using Yarn: yarn global add @quasar/cli
  • Using NPM: npm install -g @quasar/cli

Step 3: Create a New Project

Create a new Quasar project by running: quasar create <project-name>

Step 4: Start the Development Server

Run the following command to start the development server: quasar dev

Step 5: Explore the Project Structure

  • quasar.conf.js: This is the brain behind any Quasar application, because most configurations are done in this file. Quasar handles most of the complex configurations needed by the various tools and packages that you might use in an application.
  • src/assets: The assets directory contains your uncompiled assets, such as Stylus or Sass files, images, and fonts.
  • src/components: This is where all of your reusable components will live. These components make up the different parts of the application and can be reused and imported into your pages, layouts, and even other components.
  • src/css: Quasar provides this so that we can have all of our global CSS in Sass form. It consists of two files: app.sass is where all of our styles will go, while quasar.variables.sass contains all of the reusable variables we would want to make use of when styling our app. You could ignore the CSS directory if you feel it’s of no use to you.
  • src/layouts: This helps us create defined layouts for an app without repeating code. This is useful when you want to include sidebars or fixed bottom bars or have distinct layouts for mobile and desktop.
  • src/pages: The pages directory contains our application’s views and routes. Our pages are injected into the app and managed through Vue Router in /src/router/routes.js. This means that each page needs to be referenced there.
  • src/router: Contains the routing configuration.

Step 6: Build Your Application

Use Quasar’s UI components to build your application.

Example create a basic to-do list:

Add a To-Do Component
Create a new component for the to-do list. In the src/components directory, create a file named TodoList.vue

<template>
   <q-page class="q-pa-md">
      <q-input v-model="newTodo" placeholder="Add a new task" @keyup.enter="addTodo" />
      <q-btn @click="addTodo" label="Add Task" color="primary" class="q-ml-sm" />
      <q-list bordered class="q-mt-md">
         <q-item v-for="(todo, index) in todos" :key="index">
            <q-item-section>
               <q-checkbox v-model="todo.done" />
            </q-item-section>
            <q-item-section>{{ todo.text }}</q-item-section>
            <q-item-section side>
               <q-btn icon="delete" @click="removeTodo(index)" color="negative" flat />
            </q-item-section>
       </q-item>
    </q-list>
  </q-page>
</template>

<script setup>
import { ref } from 'vue';

const newTodo = ref('');
const todos = ref([]);

const addTodo = () => {
   if (newTodo.value.trim() !== '') {
      todos.value.push({ text: newTodo.value, done: false });
      newTodo.value = '';
   }
};

const removeTodo = (index) => {
   todos.value.splice(index, 1);
};
</script>

<style scoped>
.q-page {
   max-width: 600px;
   margin: auto;
}
</style>

Use the To-Do Component
Open src/pages/IndexPage.vue and use the TodoList component:

<template>
   <q-layout view="hHh lpR fFf">
      <q-header>
         <q-toolbar>
            <q-toolbar-title>Quasar To-Do App</q-toolbar-title>
         </q-toolbar>
      </q-header>

     <q-page-container>
       <TodoList />
     </q-page-container>
   </q-layout>
</template>

<script setup>
import TodoList from 'components/TodoList.vue';
</script>

Step 7: Build for Production

When you’re ready to build your application for production, run: quasar build

This will generate the output files for different platforms, such as SPA, PWA, Cordova, Capacitor, and Electron.

Step 8: Deploy Your Application

Deploy your application to your desired platform. Quasar supports various deployment targets, including web, mobile, and desktop.

Conclusion

Quasar Framework is a powerful tool for developers looking to create high-performance, cross-platform applications with ease. Its extensive component library, excellent documentation, and active community make it a standout choice in the world of web development.

References:

https://quasar.dev

Picture of Quoc Tran Kim

Quoc Tran Kim

I'm a Senior Software Engineer. With experience both Frontend and Backend, able to complete projects efficiently and satisfy customers with attractive, user-friendly websites.

Leave a Comment

Your email address will not be published. Required fields are marked *

Suggested Article

Scroll to Top