More Premium Hugo Themes Premium Nuxt Themes

Router Module

Nuxt 2 module to use router.js instead of pages/ directory.

Router Module

Nuxt 2 module to use router.js instead of pages/ directory.

Author Avatar Theme by nuxt-community
Github Stars Github Stars: 396
Last Commit Last Commit: Sep 11, 2023 -
First Commit Created: Dec 18, 2023 -
Router Module screenshot

Overview

The @nuxtjs/router module is a Nuxt.js module that allows users to use a custom router.js file instead of the pages/ directory for handling routes in their Nuxt.js application. It provides the ability to extend vue-router with Nuxt 3 using different methods.

Features

  • Ability to use a custom router.js file for handling routes in a Nuxt.js application
  • Can disable/enable the pages/ directory in Nuxt
  • Access to the same special attributes and functions as the Nuxt Page component
  • Access to the default router if used with { keepDefaultRouter: true }

Installation

To install the @nuxtjs/router module, follow these steps:

  1. Add the @nuxtjs/router dependency to your project.
  2. Add @nuxtjs/router to the buildModules section of your nuxt.config.js file. Note: If you are using Nuxt < v2.9, install the module as a dependency and use the modules section in nuxt.config.js instead of buildModules.
  3. If you are using SPA mode, add an index route to the generate section of your nuxt.config.js file.
  4. Customize the module options in the nuxt.config.js file as needed. Options include path, fileName, keepDefaultRouter, and parsePages.

Summary

The @nuxtjs/router module allows users to use a custom router.js file for handling routes in their Nuxt.js application. It provides flexibility and customization options for routing in Nuxt, including the ability to disable/enable the pages/ directory and access the default router. The module is easy to install and configure, making it a valuable tool for Nuxt.js developers.