react-nx-patterns

Organizes React and Next.js code into domain-based Nx monorepo libraries with enforced module boundaries.

Updated Jun 14, 2026
One-click install
npx skills add https://github.com/ironkid90-s/lucky5-v7 --skill react-nx-patterns-ironkid90-s
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-nx-patterns
Source: https://github.com/ironkid90-s/lucky5-v7/tree/main/.ptah/skills/react-nx-patterns
Command: npx skills add https://github.com/ironkid90-s/lucky5-v7 --skill react-nx-patterns-ironkid90-s

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Scaling React and Next.js applications in Nx monorepos often leads to tangled imports, unclear ownership, and inconsistent component architecture. This Skill provides a proven library organization pattern, component conventions, and dependency rules that keep large codebases maintainable. ## Core Features & Use Cases - Domain-Based Library Structure: Organizes code into feature, ui, data-access, util, and api-interfaces libraries with clear tagging and naming conventions. - Component Architecture Patterns: Distinguishes smart/container components from presentational components, with patterns for React Server Components, client components, Server Actions, and data fetching via React Query or Zustand. - Module Boundary Enforcement: Provides ESLint configuration for @nx/enforce-module-boundaries with tag-based dependency constraints. - Use Case: When adding a new user-management domain to a Next.js app in an Nx workspace, use this Skill to scaffold the feature, ui, and data-access libraries, wire up TypeScript paths, and enforce that UI libraries never depend on data-access code. ## Quick Start Ask the AI to set up a new domain library structure for a Next.js app in your Nx workspace following the react-nx-patterns conventions.

Frequently Asked Questions about react-nx-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I organize React libraries in an Nx monorepo?

Organize libraries by domain and type: feature libraries hold pages and smart components, ui libraries hold presentational components, data-access libraries hold API clients and state, and util libraries hold pure functions. Tag each library with scope and type for boundary enforcement.

How to set up Next.js App Router with Nx?

Create the workspace with the Next.js preset or add @nx/next to an existing workspace, then generate the app with nx g @nx/next:app. Keep the app as a thin shell that imports pages and layouts from feature libraries via TypeScript path aliases.

What is the difference between smart and presentational components in React?

Smart (container) components handle data fetching, state, and routing, and live in feature libraries. Presentational components receive data only through props, emit events via callbacks, have no external dependencies, and live in ui libraries for reuse and testability.

How do I enforce module boundaries in Nx?

Configure the @nx/enforce-module-boundaries ESLint rule with depConstraints that map source tags to allowed dependency tags. For example, ui libraries may only depend on ui, util, and api-interfaces libraries, preventing circular or layered violations.

When should I use React Server Components vs client components?

Use Server Components by default for data fetching and static rendering to minimize client bundle size. Add 'use client' only when components need interactivity, browser APIs, React hooks, or third-party libraries that depend on client-side state.

Should I use Zustand or React Query for state management?

Use React Query for server state such as fetched API data, since it handles caching, invalidation, and mutations. Use Zustand for client-only state like UI preferences, selected items, and filters, optionally with persist middleware for storage.