1 of 22

Quasar

As Cross Platform As Possible

2 of 22

Meet Elad Cohen @ GoCode

Web developers mentoring that teaches you how to code in a simple language, focused on the most current technologies in market.

Telegram channel for Hebrew materials�http://t.me/gocodesderot

Full Fullstack Course in Hebrew

http://bit.ly/gocodefed

Official Site

http://www.gocode.co.il

3 of 22

Remember?

4 of 22

Native Cross-Platform

Hybrid �(WebView based)�Cross-Platform

Quasar

Ionic

5 of 22

So, Why Quasar?

"Write code once and simultaneously deploy it"

SPAs (Single Page App)

SSR (Server-side Rendered App)

PWAs (Progressive Web App)

Mobile Apps (Android, iOS, …) through Cordova or Capacitor

Multi-platform Desktop Apps (using Electron)

6 of 22

What else?

Vue.js based

Fast and responsive web components�https://quasar.dev/vue-components/

App extensions support�https://quasar.dev/app-extensions/discover

Full RTL Supporthttps://quasar.dev/options/rtl-support#Enabling-RTL-support

40 Language Packs Out of the box�https://quasar.dev/options/quasar-language-packs

7 of 22

Great Maintenance

8 of 22

SSR Mode (aka Universal / Isomorphic)

9 of 22

SSR Mode

Lifecycle Hooks

Only beforeCreate() and created() will be called during SSR.

Code inside beforeMount() or mounted() will only be executed on the client.

Because the destroy hooks will not be called during SSR, do side-effects like setInterval only on beforeMount() or mounted() and destroy it on beforeDestroy() and destroyed() to avoid memory leaks

10 of 22

SSR Mode

PreFetch

The PreFetch is a feature which allows the components picked up by Vue Router (defined in /src/router/routes.js) to:

  • pre-fetch data
  • validate the route
  • redirect to another route, when some conditions aren’t met (like user isn’t logged in)

Can help in initializing the Store state

All the above will run before the actual route component is rendered.

11 of 22

SSR Mode

PreFetch

<!-- some .vue component used as route -->

<template>

<div>{{ item.title }}</div>

</template>

<script>

export default {

// our hook here

preFetch ({ store, currentRoute, previousRoute, redirect, ssrContext }) {

return store.dispatch('fetchItem', currentRoute.params.id)

}, ...

</script>

12 of 22

Quasar Config - quasar.config.js

13 of 22

Quasar Config - quasar.config.js

14 of 22

No main.js. Use Boot files

A common use case for Quasar applications is to run code before the root Vue app instance is instantiated.

Since you won’t be having access to any /main.js file (so that Quasar CLI can seamlessly initialize and build same codebase for SPA/PWA/SSR/Cordova/Electron) Quasar provides an elegant solution to that problem by allowing users to define so-called boot files.

import Vue from 'vue'

import axios from 'axios'

// we add it to Vue prototype

// so we can reference it in Vue files

// without the need to import axios

Vue.prototype.$axios = axios

/boot/axios.js file

15 of 22

CSS Spacing Classes

q-[p|m][t|r|b|l|a|x|y]-[none|auto|xs|sm|md|lg|xl]

T D S

T - type

- values: p (padding), m (margin)

D - direction

- values:

t (top), r (right), b (bottom), l (left),

a (all), x (both left & right), y (both top & bottom)

S - size

- values:

none,

auto (ONLY for specific margins: q-ml-*, q-mr-*, q-mx-*),

xs (extra small),

sm (small),

md (medium),

lg (large),

xl (extra large)

16 of 22

Layout Builder

17 of 22

Getting Started - SPA, SSR & PWA

npx @quasar/cli create my-app

npx quasar dev

SPA Mode

npx quasar dev -m ssr

SSR Mode

npx quasar dev -m pwa

PWA Mode

18 of 22

Getting Started - Mobile Modes

npx quasar dev -m capacitor -T [ios|android]

Capacitor Mode

npm install -g cordova�npx quasar dev -m cordova -T [ios|android]

Cordova Mode

19 of 22

Getting Started - Electron Mode

npx quasar dev -m electron

Electron Mode

20 of 22

CodeSandBox Playground

21 of 22

And live bootstrapping...

22 of 22