"Nuxt-like" routing in Quasar projects

Overview

Quasar App Extension auto-routing

"Nuxt-like" routing in Quasar projects

Install

quasar ext add auto-routing

Quasar CLI will retrieve it from the NPM registry and install the extension to your project.

Lastly, dive into src/router/routes.js and use the generated routes:

import generatedRoutes from './auto-routing' // 🤿 Here

const routes = [
  ...generatedRoutes, // 🤿 And here
  {
    path: '/',
    component: () => import('layouts/MainLayout.vue'),
    children: [
      { path: '', component: () => import('pages/Index.vue') }
    ]
  },

  // Always leave this as last one,
  // but you can also remove it
  {
    path: '/:catchAll(.*)*',
    component: () => import('pages/Error404.vue')
  }
]

export default routes

Linting

You may want to ignore linting on the auto-generated routes! Add the following at the bottom of your .eslintrc file:

/src/router/auto-routing

That's it! Start adding pages to your src/pages directory and the routing will be automagically done for you!

Also take a look at src/layouts/default.vue to change the default used layout.

A note about routePrefix

When adding a routePrefix in quasar.extensions.json, be sure to also set "nested": true inside generatorConfig. This is best shown with an example!

{
  "auto-routing": {
    "pagesDir": "src/pages",
    "routePrefix": "/admin", // 🤿 Set a prefix for routes
    "layoutsDir": "src/layouts",
    "ignorePattern": "/(^|[/\\])../",
    "outDir": "src/router/auto-routing",
    "pagesImportPrefix": "pages/",
    "generatorConfig": {
      "nested": true // 🤿 Tell the generator to treat ALL routes as nested.
    }
  }
}

References

Note that we can also proxy settings to vue-route-generator with the generatorConfig property

  • pagesDir: path to the page components
  • routePrefix: prefix all routes (e.g. /posts). See section above on "routePrefix"
  • layoutsDir: path to the layout components
  • ignorePattern: files that match this pattern will be ignored by the generator in your pages and layout dir
  • outDir: directory that holds generated routes
  • pagesImportPrefix: When generating routes, this prefix is used. By default, we use Quasar's pages alias (pages/)
  • generatorConfig: See vue-route-generator "References" for all available options

Find out more

Want to know how it all works? Take a look at vue-route-generator, which is what this App Extension is built on!

Donate

If you appreciate the work that went into this App Extension, please consider donating to Quasar.

You might also like...

A robust, minimal-server-interaction API for peer routing in the browser

A robust, minimal-server-interaction API for peer routing in the browser

Robust, minimal-server-interaction peer routing in the browser What is this? Membrane takes signalling to the browser, creating living peer networks.

Jan 6, 2023

NoExGen is a node.js express application generator with modern folder structure, namespace/project mapping and much more! It contains preconfigured Settings and Routing files, ready to be used in any project.

Installation $ npm install -g noexgen Quick Start You can use Node Package Execution to create your node-express application as shown below: Create th

Oct 8, 2022

GreenWebhook is a proxy or gateway between two systems that helps reduce your carbon footprint by dynamically routing or delaying traffic so that your workloads run when and where they will cause the lowest amount of carbon emissions.

GreenWebhook is a proxy or gateway between two systems that helps reduce your carbon footprint by dynamically routing or delaying traffic so that your workloads run when and where they will cause the lowest amount of carbon emissions.

💚 Welcome to Green Webhook! 💚 Green Webhook is a proxy or gateway between two systems that intelligently chooses which endpoint to send a webhook ev

Nov 23, 2022

A set of best practices for JavaScript projects

A set of best practices for JavaScript projects

中文版 | 日本語版 | 한국어 | Русский | Português Project Guidelines · While developing a new project is like rolling on a green field for you, maintaining it is

Jan 1, 2023

Cheatsheet for the JavaScript knowledge you will frequently encounter in modern projects.

Cheatsheet for the JavaScript knowledge you will frequently encounter in modern projects.

Modern JavaScript Cheatsheet Image Credits: Ahmad Awais ⚡️ If you like this content, you can ping me or follow me on Twitter 👍 Introduction Motivatio

Jan 4, 2023

Mini projects built with HTML5, CSS & JavaScript. No frameworks or libraries

20+ Web Projects With Vanilla JavaScript This is the main repository for all of the projects in the course. Course Link Course Info Website # Project

Jan 4, 2023

Open Source projects are a project to improve your JavaScript knowledge with JavaScript documentation, design patterns, books, playlists.

Open Source projects are a project to improve your JavaScript knowledge with JavaScript documentation, design patterns, books, playlists.

It is a project I am trying to list the repos that have received thousands of stars on Github and deemed useful by the JavaScript community. It's a gi

Aug 14, 2022

A Web UI toolkit for creating rapid prototypes, experiments and proof of concept projects.

MinimalComps2 A Web UI tookkit for creating rapid prototypes, experiments and proof of concept projects. The site: https://www.minimalcomps2.com/ Full

Apr 18, 2022

A refined tool for exploring open-source projects on GitHub with a file tree, rich Markdown and image previews, multi-pane multi-tab layouts and first-class support for Ink syntax highlighting.

A refined tool for exploring open-source projects on GitHub with a file tree, rich Markdown and image previews, multi-pane multi-tab layouts and first-class support for Ink syntax highlighting.

Ink codebase browser, "Kin" 🔍 The Ink codebase browser is a tool to explore open-source code on GitHub, especially my side projects written in the In

Oct 30, 2022
Comments
  • RouterLayout should be Generated named static import instead of dynamic import for Vite.

    RouterLayout should be Generated named static import instead of dynamic import for Vite.

    Quasar with Webpack is still working without problem. but, when I using Vite, it's not working. Due to lack of supported dynamic routes on Rollup, layout will not exposed, so Quasar with Vite will render nothing. but if it generate as named dynamic static import like this:

    const RouterLayout = createRouterLayout(layout => {
      switch(layout) { // or plain object or more something template that awesome...
          // user created layout files:
          case 'some': return import('layouts/some.vue');
          case 'other': return import('layouts/other.vue');
          // default layout:
          default: return import('layouts/default.vue'); // or as configure
      }
    })
    

    I think it will works like charm even using Vite. If you not excused, I'll make a pull request after test.

    opened by composite 1
  • Bad description in readme.md about eslint

    Bad description in readme.md about eslint

    Hi,

    In the readme.md, there is a mistake about the eslint file you must modify to ignore auto-routing. You must update .eslintignore, not .eslintrc.

    btw, it's a very interesting extension for someone who comes from nuxt. Good job :)

    opened by arsenikstiger 1
Owner
Luke Diebold
Vue + Quasar + Vuex-ORM + Orion = Bliss!
Luke Diebold
quASAR: ASAR manipulation made easy

quASAR quASAR: ASAR manipulation made easy This project is a proof-of-concept for manipulating ASAR files for code injection in Electron apps. This ca

Michael Taggart 19 Sep 25, 2022
Online store with Medusajs and Quasar Framework 🛒

Medusa Ecommerce Vue ?? Online store with Medusajs and Quasar Framework medusa-cli First install medusa cli in your environment yarn global add @medus

Patrick Monteiro 22 Oct 20, 2022
Michael Schneider 4 Oct 26, 2022
Example project implementing authentication, authorization, and routing with Next.js and Supabase

Magic Link Authentication and Route Controls with Supabase and Next.js To run this project, To get started with this project, first create a new proje

Nader Dabit 134 Dec 11, 2022
Example code for MFE routing, shared state, build-time & runtime deploy video

Turborepo starter with pnpm This is an official starter turborepo. What's inside? This turborepo uses pnpm as a packages manager. It includes the foll

Jack Herrington 42 Nov 2, 2022
Lit + File Based Routing + Nested Layouts

Lit File Based Routing Lit router for nested layouts and file based routing. Similar to https://remix.run/ but at client side. Demo Package Archived i

Rody Davis 9 Jan 14, 2022
It shows how to escape cross-origin issues for web client and API server using CloudFront routing.

AWS CloudFront의 URL Routing을 이용한 Web Client 및 API Server 구현 여기서는 CliendFront의 URL Routing을 이용하여 Web Client와 API Server를 구현하고자 합니다. Web Client는 Amazon

John Park 4 Nov 20, 2022
A tiny foundation that providing nested state-based routing for complex web application.

StateMan stateman: A tiny foundation that provides nested state-based routing for complex web applications. stateman is highly inspired by ui-router;

ZhengHaibo 390 Dec 20, 2022
Zemi is data-driven and reverse-routing library for Express. It provides out-of-the-box OpenAPI support, allowing you to specify and autogenerate an OpenAPI spec.

zemi zemi is a data-driven routing library for Express, built with Typescript. Features: optional, out-of-the-box support for OpenAPI reverse-routing

Yoaquim Cintrón 5 Jul 23, 2022
A minimal routing library designed to sit on top of Bun's fast HTTP server.

siopao A minimal routing library designed to sit on top of Bun's fast HTTP server. Based on Radix Tree. Sio=Hot Pao=Bun Installation bun add siopao Us

Robert Soriano 69 Nov 8, 2022