Skip to content

giuseppe-trisciuoglio/developer-kit / plugins/developer-kit-typescript/skills/nx-monorepo

nx-monorepo

Verified

Provides comprehensive Nx monorepo management guidance for TypeScript/JavaScript projects. Use when creating Nx workspaces, generating apps/libraries/components, running affected commands, setting up CI/CD, configuring Module Federation, or implementing NestJS backends within Nx

FileKindSize
SKILL.mdskill md8.9 KB
references/advanced.mdmarkdown7.4 KB
references/basics.mdmarkdown3.9 KB
references/ci-cd.mdmarkdown7.8 KB
references/generators.mdmarkdown5.2 KB
references/nestjs.mdmarkdown7.1 KB
references/react.mdmarkdown6.3 KB
references/typescript.mdmarkdown6.8 KB

references/react.md

View on GitHub
# React / Next.js / Expo Reference

## React Applications

### Create React App

```bash
# Vite (recommended)
nx g @nx/react:app my-app --style=scss

# Webpack
nx g @nx/react:app my-app --bundler=webpack

# With routing
nx g @nx/react:app my-app --routing

# With standalone mode (React 19+)
nx g @nx/react:app my-app --standalone
```

### React Library

```bash
# Buildable library
nx g @nx/react:lib shared-ui --style=scss

# Publishable npm package
nx g @nx/react:lib design-system --publishable --importPath=@myorg/design-system

# With directory structure
nx g @nx/react:lib ui-components --directory=libs/shared/ui
```

### React Component Generator

```bash
# Basic component
nx g @nx/react:component Button --project=shared-ui

# With all options
nx g @nx/react:component Header \
  --project=web-app \
  --style=scss \
  --export \
  --skipTests \
  --flat
```

### Project Configuration

```json
{
  "name": "web-app",
  "projectType": "application",
  "sourceRoot": "apps/web-app/src",
  "targets": {
    "build": {
      "executor": "@nx/vite:build",
      "outputs": ["{workspaceRoot}/dist/apps/web-app"],
      "configurations": {
        "production": {
          "mode": "production"
        },
        "development": {
          "mode": "development"
        }
      }
    },
    "serve": {
      "executor": "@nx/vite:dev-server",
      "configurations": {
        "production": {
          "buildTarget": "web-app:build:production"
        }
      }
    },
    "test": {
      "executor": "@nx/vite:test"
    },
    "lint": {
      "executor": "@nx/linter:eslint"
    }
  }
}
```

## Next.js Applications

### Create Next.js App

```bash
# Pages router
nx g @nx/next:app my-next-app

# App directory (Next.js 13+)
nx g @nx/next:app my-next-app --style=scss

# With custom directory
nx g @nx/next:app my-next-app --directory=apps/next
```

### Next.js Project Configuration

```json
{
  "targets": {
    "build": {
      "executor": "@nx/next:build",
      "outputs": ["{workspaceRoot}/dist/apps/next-app"],
      "configurations": {
        "production": {},
        "development": {}
      }
    },
    "serve": {
      "executor": "@nx/next:server"
    },
    "export": {
      "executor": "@nx/next:export"
    }
  }
}
```

### Serve Next.js

```bash
# Development
nx serve my-next-app

# Production build serve
nx start my-next-app
nx serve my-next-app --prod
```

## Expo / React Native

### Create Expo App

```bash
nx g @nx/expo:app my-mobile-app
```

### Serve Expo App

```bash
# Web
nx start my-mobile-app --web

# iOS
nx start my-mobile-app --ios

# Android
nx start my-mobile-app --android
```

## Module Federation

### Micro-Frontend Setup

```bash
# Host application
nx g @nx/react:host shell-app

# Remote application
nx g @nx/react:remote checkout-app --name=checkout --port=4201

# Add remote to host
nx g @nx/react:remote-configuration shell-app \
  --remote=checkout \
  --port=4201 \
  --type=module
```

### Module Federation Config

Webpack configuration for module federation is automatically generated. Key files:

```
apps/shell-app/
├── module-federation.config.ts
└── src/
    ├── app/
    │   ├── app.component.tsx
    │   └── routes.tsx
    └── bootstrap.tsx
```

Load remote module:

```tsx
// routes.tsx
import { loadRemoteModule } from '@angular-architects/module-federation';

export const routes: Routes = [
  {
    path: 'checkout',
    loadChildren: () =>
      loadRemoteModule({
        type: 'module',
        remoteEntry: 'http://localhost:4201/remoteEntry.js',
        exposedModule: './Module'
      }).then(m => m.RemoteModule)
  }
];
```

## Tailwind CSS

### Setup Tailwind

```bash
# React project
nx g @nx/react:setup-tailwind my-app

# With custom stylesheet
nx g @nx/react:setup-tailwind my-app --stylesEntryPoint=apps/my-app/src/styles.scss
```

### Nx React Webpack Plugin

Configure for custom webpack:

```javascript
const { NxReactWebpackPlugin } = require('@nx/react/webpack-plugin');

module.exports = {
  plugins: [
    new NxReactWebpackPlugin({
      svgr: false, // Disable SVGR
    }),
  ],
};
```

## Storybook

### Setup Storybook for Library

```bash
# React library
nx g @nx/react:storybook-configuration shared-ui

# Run Storybook
nx storybook shared-ui

# Build Storybook
nx build-storybook shared-ui
```

### Storybook Composition

For composed Storybooks (multiple libraries):

```bash
# Start individual instances
nx storybook ui-lib-1  # Port: 4400
nx storybook ui-lib-2  # Port: 4401
```

## Testing

### Vitest (Recommended for Vite)

```bash
# Test project
nx test my-react-app

# Watch mode
nx test my-react-app --watch

# UI mode
nx test my-react-app --ui

# Coverage
nx test my-react-app --coverage
```

### Component Testing

```bash
# Component with test
nx g @nx/react:component Button --project=shared-ui
```

Test example:

```tsx
// button.component.spec.tsx
import { render, screen } from '@testing-library/react';
import { Button } from './button';

describe('Button', () => {
  it('renders with text', () => {
    render(<Button text="Click me" />);
    expect(screen.getByText('Click me')).toBeInTheDocument();
  });
});
```

### E2E Testing

```bash
# Add Cypress to app
nx g @nx/cypress:cypress-project my-app-e2e --bundler=vite

# Run E2E
nx e2e my-app-e2e

# Run with UI
nx e2e my-app-e2e --watch
```

## Common Patterns

### Shared UI Library

```bash
# 1. Create library
nx g @nx/react:lib design-system --style=scss --importPath=@myorg/design-system

# 2. Add components
nx g @nx/react:component Button --project=design-system --export
nx g @nx/react:component Input --project=design-system --export
nx g @nx/react:component Card --project=design-system --export

# 3. Build library
nx run design-system:build

# 4. Use in app
// apps/web-app/src/app/app.tsx
import { Button } from '@myorg/design-system';
```

### Feature Libraries

```bash
# Feature-specific libraries
nx g @nx/react:lib feature-auth --directory=libs/features --tags=scope:auth,type:feature
nx g @nx/react:lib feature-checkout --directory=libs/features --tags=scope:checkout,type:feature
nx g @nx/react:lib feature-catalog --directory=libs/features --tags=scope:catalog,type:feature

# Run tests for all features
nx run-many -t test --projects=tag:type:feature
```

### Library Dependencies

```json
// project.json for web-app
{
  "targets": {
    "build": {
      "dependsOn": [
        { "projects": ["shared-ui"], "target": "build" }
      ]
    }
  }
}
```
writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deploymentStars: 322kUpdated Claude CodeCodexVerifiedInstall
xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release.Stars: 118kUpdated Claude CodeCodexVerifiedInstall