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

nxt-modular

v1.0.3

Published

CLI generator for Next.js modular architecture (Page Router & App Router)

Downloads

369

Readme

Berikut versi README.md yang sudah DIUPDATE agar konsisten dengan fitur flag --src dan perilaku generator terbaru.

Perubahan utama:

  • ❌ Tidak lagi mengasumsikan src/ sebagai default
  • ✅ Menjelaskan dua mode struktur: root-based dan src-based
  • ✅ Menambahkan dokumentasi flag --src di semua bagian relevan
  • ❌ Tidak mengubah filosofi / aturan inti

💎 nxt-modular

The Strict Modular Architecture Generator for Next.js

🔗 Repository: https://github.com/firzaelbuho/nxt-modular 📦 NPM: https://www.npmjs.com/package/nxt-modular


📌 Overview

nxt-modular is a CLI generator for building a strict modular architecture in Next.js, supporting both the Page Router and the App Router.

This tool enforces architectural discipline, not just scaffolding:

  • 1 page = 1 module
  • Dumb store
  • Dumb UI
  • All mutations go through services
  • No any
  • No logic inside route files
  • No cross-module imports

If you are looking for a “quick but messy” generator, this tool is not for you.


📋 Table of Contents

  1. Installation
  2. Quick Start
  3. CLI Commands
  4. Directory Modes (--src)
  5. Supported Routers
  6. Architecture Philosophy
  7. Module Structure
  8. State Management Rules
  9. Routing Rules
  10. Styling Rules
  11. License

📦 Installation

Using Bun (Recommended)

# Run directly
bunx nxt-modular create home

# Or install globally
bun add -g nxt-modular

Using NPM / PNPM

npm install -g nxt-modular
# or
pnpm add -g nxt-modular

🚀 Quick Start

Create a Module (Page Router, default)

bunx nxt-modular create home

Output (no src/):

modules/home/
pages/home/index.tsx

Create a Module (Page Router, with src/)

bunx nxt-modular create home --src

Output:

src/modules/home/
src/pages/home/index.tsx

Create a Module (App Router, default)

bunx nxt-modular create-app home

Output (no src/):

modules/home/
app/home/page.tsx

Create a Module (App Router, with src/)

bunx nxt-modular create-app home --src

Output:

src/modules/home/
src/app/home/page.tsx

🛠 CLI Commands

create <name>

Generate a Next.js Page Router module.

nxt-modular create user-profile
nxt-modular create user-profile --src

Generated:

  • modules/user-profile/ or src/modules/user-profile/
  • pages/user-profile/index.tsx or src/pages/user-profile/index.tsx

create-app <name>

Generate a Next.js App Router module.

nxt-modular create-app dashboard
nxt-modular create-app dashboard --src

Generated:

  • modules/dashboard/ or src/modules/dashboard/
  • app/dashboard/page.tsx or src/app/dashboard/page.tsx

📂 Directory Modes (--src)

nxt-modular supports two official directory layouts.

1️⃣ Root-based (default)

Used by many Next.js projects.

modules/
pages/
app/

Command:

nxt-modular create home

2️⃣ src/-based (opt-in)

Used by teams that prefer stricter separation.

src/
├── modules/
├── pages/
└── app/

Command:

nxt-modular create home --src

--src is explicit by design. The generator does not auto-detect to avoid ambiguity.


🔀 Supported Routers

| Router Type | Supported | | ---------------------- | --------- | | Page Router (pages/) | ✅ | | App Router (app/) | ✅ |

Important:

  • Page Router → index.tsx
  • App Router → page.tsx
  • Do not mix conventions

🏛 Architecture Philosophy

nxt-modular enforces Strict Modularity:

  1. One Page = One Module
  2. No Circular Dependencies
  3. No Cross-Module Imports
  4. Strict TypeScript (no any)
  5. Unidirectional Data Flow

Mental Model

UI renders. Store stores. Service decides. Route loads only.


🧱 Module Structure

Example: home

modules/home/
├── index.tsx        <- Module UI root (client)
├── store.ts         <- Zustand store (state only)
├── service.ts       <- All mutations & logic
├── types.ts         <- UI state types
├── values.ts        <- Default state
└── components/      <- Module-only components

When using --src, the same structure lives under src/modules/.

Rules

  • Modules cannot import other modules
  • Shared code must live in shared/ or src/shared/
  • index.tsx is the only UI entry point

🧠 State Management Rules (Zustand)

Store (store.ts)

  • ❌ No logic
  • ❌ No async
  • ❌ No actions
  • ✅ State only

Service (service.ts)

  • setState
  • ✅ async / fetch
  • ✅ business rules
  • ✅ orchestration

UI

  • ❌ Mutate store
  • ❌ Fetch data
  • ❌ Business logic
  • ✅ Call service functions

🧭 Routing Rules

Page Router

import HomePage from "@/modules/home";

export default function Page() {
  return <HomePage />;
}

App Router

import HomePage from "@/modules/home";

export default function Page() {
  return <HomePage />;
}

Route files are dumb loaders. Period.


🎨 Styling Rules

This architecture mandates:

  • TailwindCSS
  • DaisyUI

Styling Rules

  • ❌ Inline styles
  • ❌ Hardcoded colors
  • ❌ Random CSS
  • ✅ Tailwind utilities
  • ✅ DaisyUI components (btn, card, modal)

Layout Guidelines

  • Use max-w-5xl mx-auto
  • Split UI into section components
  • Mobile-first, responsive grids

❌ What This Tool Intentionally Does NOT Do

  • ❌ Auto-generate API routes
  • ❌ Manage databases
  • ❌ Provide magic state shortcuts
  • ❌ Allow architectural shortcuts

This tool optimizes for long-term sanity, not short-term speed hacks.


📄 License

MIT License © firzaelbuho


nxt-modular Strict architecture. No shortcuts.