---
title: "Monorepos"
description: "One root config with projects, each project with its own locales and its own config."
canonical_url: "https://x18n.dev/guide/monorepos"
---
# Monorepos

> One root config with projects, each project with its own locales and its own config.

A monorepo can hold several projects, for example a web app and a UI library, each with its own locale files. List them in the root config with `projects`:

```ts [x18n.config.ts]
import { defineConfig } from '@x18n/core'

export default defineConfig({
  sourceLocale: 'en',
  projects: ['apps/*', 'packages/ui'],
})
```

Each entry of `projects` is a glob of directories, relative to the root config. Each matching directory is one project.

## Project configs

A project directory can have its own `x18n.config.*`. The project inherits the options of the root config, and its own config overrides them. The rules are the same as for one project: see [How x18n merges the config](https://x18n.dev/guide/configuration#how-x18n-merges-the-config).

```ts [apps/web/x18n.config.ts]
import { defineConfig } from '@x18n/core'

export default defineConfig({
  resources: [
    { pattern: 'locales/{locale}.json' }
  ],
  checks: {
    'unused-key': 'error',
  },
})
```

Paths in a project config are relative to the project directory. A project directory without a config file is a project with the root options and its own detection.

Plugins of the root config and of the project config both apply. Presets of the project config replace the presets of the root config.

## Without a root config

A monorepo does not need a root config. When x18n finds no config in the current directory or above it, it looks for configs below it, skipping `node_modules`. Each config it finds is a project, or a root config with its own `projects`. The projects do not share options.

```txt
apps/web/x18n.config.ts
apps/docs/x18n.config.ts
```

Open the monorepo root in the editor and it shows both projects. Each file belongs to the project with the deepest root that holds it, so hover, completion, diagnostics and the **Open UI** command use the project of the current file.

## Project names

The name of a project is its path from the root, such as `apps/web`, unless its config sets `name`. `x18n status` lists the names.

## Commands

Read commands work on every project:

- `x18n check` checks every project, and reports them together.
- `x18n status`, `x18n keys` and `x18n usages` show every project.
- The UI and the editor show every project.

Pass `--project <name>` to work on one project. Commands that write files (`set`, `apply`, `rename`, `delete`, `fill`, `format`, `extract`) and `x18n prompt` need one project. Without `--project`, they stop with [X18N0003](https://x18n.dev/errors/x18n0003).

```sh
x18n check --project apps/web
x18n set nav.home --value "Home" --project apps/web
```

Run the commands from the root of the monorepo. The CLI uses the first config file that it finds from the current directory upward. If you run it in `apps/web`, it finds `apps/web/x18n.config.ts` first and loads that project alone, without the root options.


## Sitemap

See the full [sitemap](https://x18n.dev/sitemap.md) for all pages.
