Simplicidade de criar PWAs com o framework Quasar

Posted on: November 20, 2025 04:11 PM

Posted by: Renato

Categories: vue

Views: 111

Simplicidade de criar PWAs com o framework Quasar

Explore the simplicity and power of building PWAs with the Quasar framework.

Se você está aqui, provavelmente já conhece o Quasar, o robusto framework baseado em Vue.js. Mas, se não conhece, sem problema algum! Você está prestes a aprender algo novo.

Aqui estão alguns tipos de aplicações que podem ser criadas usando Quasar:

1. Progressive Web Apps (PWAs)
2. Single Page Applications (SPAs)
3. Aplicações Multiplataforma
4. Aplicações Mobile
5. Aplicações com Renderização no Servidor (SSR)
6. Aplicações Híbridas

Neste artigo, vou te guiar por como você pode aproveitar o Quasar para criar Progressive Web Apps de forma fácil e eficiente.

Vamos começar entendendo os motivos para escolher o Quasar em vez do Vue.js puro quando se trata de criar Progressive Web Applications (PWAs).
O Quasar oferece diversos recursos que tornam o desenvolvimento de PWAs mais simples e rápido, incluindo:

**Scaffolding:** O Quasar vem com um CLI que pode ser usado para gerar uma estrutura básica de projeto PWA, incluindo os arquivos de configuração necessários. Isso elimina a necessidade de configurar o projeto manualmente, economizando tempo e esforço.

**Componentes de UI:** O Quasar fornece uma ampla biblioteca de componentes de interface prontos, que podem ser usados para construir PWAs. Esses componentes são projetados para serem amigáveis em dispositivos móveis e fáceis de usar, reduzindo ainda mais o tempo de desenvolvimento.

**Geração de código:** O Quasar também inclui uma ferramenta de geração de código que pode criar trechos para funcionalidades comuns de PWAs, como rotas, serviços e diretivas. Isso diminui ainda mais a quantidade de código que os desenvolvedores precisam escrever manualmente.

**Integração de plugins:** O Quasar integra perfeitamente plugins e bibliotecas populares do Vue, como Vue Router, Vuex e Axios. Isso permite que os desenvolvedores utilizem essas ferramentas sem se preocupar com problemas de compatibilidade.

Por todos esses motivos, a configuração de PWA com Quasar é muito melhor do que uma PWA comum com Vue.js, em termos de desenvolvimento.

---

## Tutorial de PWA com Quasar para o **Blogify**

No Blogify, vamos integrar os principais recursos de PWAs usando Quasar, incluindo:

🏠 Instalação na Tela Inicial
🔄 Precaching
📊 Estratégias de Cache
🔄 Sincronização em Segundo Plano (Background Sync)
🔔 Notificações Push

Você vai aprender a transformar o Blogify — uma plataforma similar ao Medium — em uma Progressive Web App usando Quasar. Isso permitirá criar um site e um app com recursos empolgantes, semelhantes aos de aplicativos mobile nativos.

Mas espere: antes de começarmos a construir nossa obra-prima “Blogify”, vamos fazer um rápido tour de demonstração para ver o que vem pela frente.

 

Experience the live demonstration: Quasar-blogify.

If you’re all set, let’s dive into creating your “Blogify” masterpiece using Quasar v2, Firebase, Node, Express, and Vue 3! 🚀

Prerequisites:

Ensure Node is >=14 (or a newer LTS version) and NPM is >=6.14.12 or Yarn is >=1.21.1 installed on your machine.

Setting Up Your Project:

Let’s install Quasar using CLI and create a new Quasar Project:

npm i -g @quasar/cli
npm init quasar
Press enter or click to view image in full size

Once the project is created, execute the following commands:

cd quasar-blogify
 quasar dev # or: yarn quasar dev # or: npx quasar dev

It will run the project, as shown below:

Press enter or click to view image in full size

You can see the folder structure of the Quasar project below:

You can save development time by exploring my GitHub repository for PWA development. It’s packed with ready-to-use code for CRUD operations and essential Quasar features. Use it as your guide to speed up your progress.

GitHub Repository: Blogify

Create Layout, add pages, and create components.

Press enter or click to view image in full size

Once you’ve configured layout pages, components, and routing, the UI will appear as shown below (the card currently contains static data):

Press enter or click to view image in full size

Following the establishment of the basic layout, let’s proceed to connect to the database and backend.

Create a Firebase project

  • Create a new Firebase project called “Blogify” here.

Create a Cloud Firestore database

  • Create a Cloud Firestore database (make sure you start in test mode).
  • Add a collection named “blogs.”
  • Add some dummy blog data.
  • Each blog should have the fields id, title, content, liked, favorite, created_at.

Setup a Node.js and Express backend

  • Create a subfolder for your backend and initialize with npm in it.
  • Install Express and Nodemon.
  • Create an Express app with a simple GET endpoint that returns a string.
  • Launch the app and make sure the endpoint works in the browser.

Get the app running

  • Create a new project using the Firebase Console named Blogify (disable Google Analytics).
  • On the Project Overview page, click on the Web icon below Get started by adding Firebase to your app.
  • Name the app Blogify and click Register app.
Press enter or click to view image in full size
  • Click Continue to console.
  • Click on 1 app > Settings icon > Service accounts.
  • You may need to click Create Service account.
  • Copy the databaseURL from the code sample and paste it into backend/index.js in your project.
  • Save index.js .
  • On Firebase Console — Click Generate new private key > Generate key.
  • Save the JSON file to your backend folder and rename it to serviceAccountKey.json .
Press enter or click to view image in full size
  • On Firebase Console — Click Database > Create database > Start in test mode > Choose a location > Click Done.

The provided code in index.js initializes the Firebase Database and includes all the endpoints for our Blogify app.

  • Install dependencies for both the app and server:
npm install
cd backend
npm install
  • Launch the backend server:
cd backend
npm start
  • Launch the app in PWA mode and ensure it’s working:
quasar dev -m pwa

Executing this command generates a src-pwa folder. We’ll explore it shortly and update custom-service-worker.js for our app.

Our app is now running in PWA mode. A noticeable change is the installation icon in the address bar.

Press enter or click to view image in full size
PWA mode

Every PWA requires a manifest file, a JSON file that informs the browser about how the app should be displayed. It includes details like titles, descriptions, colors, icons, and whether the app should be on full screen or retain some browser elements.

For a PWA without Quasar, we’d manually create the manifest JSON file and link it to our homepage using a tag like this.

<link rel="manifest" href="manifest.json" >

Quasar automatically generates and links the manifest.json file, eliminating the need for the above tag. View the manifest.json by opening http://localhost:9200/manifest.json while running your project.

Press enter or click to view image in full size

The manifest.json file includes details like name, orientation, and background color. Customize it for changes such as updating your app’s name.

1. Home screen installation 🏠

We’ll enhance our app by integrating a visually appealing banner for home screen installation. This banner will only appear on supported devices when the app is ready to install and users can choose to hide it if they find it annoying.

Get Divya Sonara’s stories in your inbox

Update your MainLayout.vuewith this piece of code:

    ```vue
 <template>
 
      
Install Blogify?