npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

nuxt-module-structure

v1.5.11

Published

The Nuxt Module Structure package allows you to create a modular architecture for your Nuxt applications, organizing your code into layers. This helps in maintaining a clean structure, especially for large applications. [Nuxt Layers](https://nuxt.com/docs

Readme

Nuxt Module architecture

The Nuxt Module Structure package allows you to create a modular architecture for your Nuxt applications, organizing your code into layers. This helps in maintaining a clean structure, especially for large applications. Nuxt Layers Documentation

You can find the official documentation for Nuxt Layers here: 🔗 Nuxt Layers

Installation

To initialize the main modules, run:

npm run init-modules ./ -i18n

Replace ./ with your desired path for the main modules. If you need to configure i18n, include it as shown.

Usage

When you run the initialization command, you will be prompted for:

  1. Name of the main module: The default name is app.
  2. Authentication module: The default is to create an authentication module.

Directory Structure

Upon execution, the following directory structure will be created:

modules/
  ├── app/
  │   ├── pages/
  │   ├── layouts/
  │   ├── components/
  │   └── store/
  └── auth/
      ├── pages/
      ├── layouts/
      ├── components/
      └── store/

Each module will automatically have its path added to the nuxtModuleConfig:

nuxtModuleConfig: {
  dir: {
        pages: "./pages",         // Custom pages directory
        layouts: "./layouts",     // Custom layouts directory
    //  plugins:"./plugins",      // Custom plugins directory  
    //  assets: "./assets",       // Custom assets directory
    //  middleware: "./middleware", // Custom middleware directory
  },
  extends: ["<layer-path>"]
}

Next step

Adding Separate Modules

To add a separate module in the future, run:

npm run add-module ./modules/app about-us
  • ./modules/app :
  • about-us:

You can specify additional configurations such as:

  • i18n (if you need internationalization)
  • store (if you need a pinia store)
  • layout (if you need a layout)
npm run add-module ./modules/app about-us i18n store layout

Outbut

modules/
  ├── app/
  │   ├── pages/
  │   ├── layouts/
  │   ├── components/
  │   ├── store/
  │   └── about-us/   # Add the about-us module here
  │       ├── pages/
  │       ├── layouts/
  │       ├── components/
  │       ├── i18n/
          └── store/
  └── auth/
      ├── pages/
      ├── layouts/
      ├── components/
      └── store/

⚠️ Warning: Proper Module Structure

When adding a child module inside a parent module, always create a modules/ directory inside the parent module and place the child module inside it.

Correct Structure:

modules/
├── app/
│   ├── pages/
│   ├── layouts/
│   ├── components/
│   ├── store/
│   └── modules/   # Create this directory inside the parent module
│       ├── profile/  # Add child modules inside “modules/”
│       │   ├── pages/
│       │   ├── layouts/
│       │   ├── components/
│       │   └── store/
└── auth/
├── pages/
├── layouts/
├── components/
└── store/

❌ Incorrect Structure:

modules/
├── app/
│   ├── pages/
│   ├── layouts/
│   ├── components/
│   ├── store/
│   ├── profile/  # ❌ Do NOT add child modules directly here
└── auth/

Why is this important?

  • Keeps the module hierarchy clean and organized.
  • Prevents conflicts and confusion when adding new modules.
  • Ensures consistency across the project

Module Auto-Generation

Page Creation

When adding a module, a page is automatically created inside the pages directory:

├── home/
│   ├── pages/
│         ├────/home.vue
│
│────────────────────

home.vue

  <template>
    <div class="">${filename} page</div>
  </template>
  <script lang="ts" setup>
  definePageMeta({
   // layout: "module-lay",
  });
  </script>

###homeStore.ts

  import { defineStore } from "pinia";
  const useModuleNameStore = defineStore("useModuleNameStore", () => {});
  export default useuseModuleNameStoreStore;

Is Store

###Store Setup

├── module-name/
│   ├── store/
│         ├────/moduleNameStore.ts
│
│────────────────────

###moduleNameStore.ts

  import { defineStore } from "pinia";
  const useModuleNameStore = defineStore("useModuleNameStore", () => {});
  export default useuseModuleNameStoreStore;

Layout Setup

Each module includes a layout file:

├── module-name/
│   ├── Layouts/
│         ├────/module-name-lay.vue
│
│────────────────────

###module-name-layout.vue

  <script setup lang="ts">
  // import parent layout what you want and wrap solt inside it to make sited layout 
  // import ParentLayout from "../../layouts/*****.vue" 
  </script>
  
  <template>
  <!-- <pearnt-layout>  -->
      <slot />
      <!--  <pearnt-layout> -->
  </template>

Is i18n

###If i18n is not initialized when creating modules, running add-module --i18n will automatically generate i18n.config.ts in the root project.

├── root/
│   ├── i18n/
│         ├────/global
│                 ├────/en.ts
│                  ├────/ar.ts
│         ├────/i18n.config.ts
│
│────────────────────

i18n.config.ts

export default {
}
import en from "./global/en"
import ar from "./global/ar"

export default defineI18nConfig(() => ({
  legacy: false,
  locale: "ar",
  fallbackLocale: "",
  messages: {
    en: {
      ...en,
    },
    ar: {
      ...ar,
    },
  },
}));

Global Translation Files (en.ts / ar.ts)

export default {
}

##Using i18n as a Composable in components


 import ar from "../i18n/ar";
 import en from "../i18n/en";
 import { useI18n } from "vue-i18n";
 const { t } = useI18n({
   messages: {
     en: en,
     ar: ar,
   },
 });