Monorepo (Nx) Setup for Web Project

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.
Development and maintenance of all types of websites:
Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Showing 1 of 1 servicesAll 2065 services
Monorepo (Nx) Setup for Web Project
Complex
~3-5 business days
FAQ
Our competencies:
Development stages
Latest works
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    822
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    847
  • image_website-sbh_0.png
    Website development for SBH Partners
    999
  • image_website-_0.png
    Website development for Red Pear
    451

Monorepo Setup (Nx) for Web Project

Nx—not just build system with caching, but full monorepo platform: code generators, plugins for each framework, dependency graph visualization, run only affected projects. Suitable for large teams and complex projects where Turborepo feels insufficient.

Nx vs Turborepo: Principal Difference

Turborepo—task runner with cache. Doesn't understand package contents.

Nx—understands structure: knows this is Next.js app, that one is NestJS, can generate components, modules, tests by templates. Plugin @nx/next configures caching rules, generators, tasks—all automatic.

Turbo fits when stack exists and need speed. Nx fits when team large and need development standardization.

Initialization

# New workspace
npx create-nx-workspace@latest acme --preset=apps
cd acme

# Add applications
npx nx generate @nx/next:app web --directory=apps/web
npx nx generate @nx/react:app admin --directory=apps/admin --bundler=vite
npx nx generate @nx/node:app api --directory=apps/api --framework=express

# Add libraries
npx nx generate @nx/react:lib ui --directory=packages/ui --component
npx nx generate @nx/js:lib utils --directory=packages/utils
npx nx generate @nx/js:lib types --directory=packages/types --bundler=none

Structure and nx.json

// nx.json
{
  "$schema": "./node_modules/nx/schemas/nx-schema.json",
  "targetDefaults": {
    "build": {
      "cache": true,
      "dependsOn": ["^build"],
      "inputs": ["production", "^production"]
    },
    "lint": {
      "cache": true,
      "inputs": [
        "default",
        "{workspaceRoot}/.eslintrc.json",
        "{workspaceRoot}/.eslintignore"
      ]
    },
    "test": {
      "cache": true,
      "inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"]
    },
    "typecheck": {
      "cache": true
    }
  },
  "namedInputs": {
    "default": ["{projectRoot}/**/*", "sharedGlobals"],
    "production": [
      "default",
      "!{projectRoot}/**/*.spec.*",
      "!{projectRoot}/jest.config.*",
      "!{projectRoot}/.eslintrc.json"
    ],
    "sharedGlobals": []
  },
  "generators": {
    "@nx/react": {
      "component": {
        "style": "none",
        "classComponent": false
      }
    }
  },
  "defaultBase": "main"
}

project.json for Each Project

Nx uses project.json instead of scripts in package.json:

// apps/web/project.json
{
  "name": "web",
  "$schema": "../../node_modules/nx/schemas/project-schema.json",
  "sourceRoot": "apps/web/src",
  "projectType": "application",
  "targets": {
    "build": {
      "executor": "@nx/next:build",
      "outputs": ["{options.outputPath}"],
      "defaultConfiguration": "production"
    },
    "serve": {
      "executor": "@nx/next:server",
      "defaultConfiguration": "development"
    }
  },
  "tags": ["type:app", "scope:web"]
}

Tags and Lint Rules for Architectural Constraints

Nx strength—enforce module boundaries:

// .eslintrc.json
{
  "plugins": ["@nx"],
  "rules": {
    "@nx/enforce-module-boundaries": [
      "error",
      {
        "depConstraints": [
          {
            "sourceTag": "type:app",
            "onlyDependOnLibsWithTags": ["type:lib"]
          },
          {
            "sourceTag": "scope:web",
            "onlyDependOnLibsWithTags": ["scope:web", "scope:shared"]
          }
        ]
      }
    ]
  }
}

Dependency Graph

# Browser visualization
npx nx graph

# Affected by branch changes
npx nx affected:graph

Run Only Affected Projects

# Tests for affected only
npx nx affected:test

# Build changed
npx nx affected:build --base=origin/main --head=HEAD

# Parallel, max 4 tasks
npx nx affected:build --parallel=4

Generators: Standardize Development

Nx lets write custom generators—scripts creating files by templates.

Nx Cloud: Distributed Task Execution

Distribute tasks across multiple CI agents:

# .github/workflows/ci.yml
jobs:
  agents:
    strategy:
      matrix:
        agent: [1, 2, 3]
    steps:
      - run: npx nx-cloud start-agent

  main:
    steps:
      - run: npx nx-cloud start-ci-run --distribute-on="3 linux-medium-js"
      - run: npx nx affected -t lint typecheck test build

Timeline

Setup Nx for 6–10 projects—3–5 days: workspace, plugins, module boundaries, generators, CI/CD. Migrate existing monorepo—1–1.5 weeks depending on custom configs.