# native-components.json (/docs/native/cli/configuration)

Written by `init`, next to your components. The nearest one wins, walking up from `--cwd`.

```json title="native-components.json"
{
  "$schema": "https://raw.githubusercontent.com/delacournz/delacour-ui/main/registry/config.schema.json",
  "version": 2,
  "framework": "expo",
  "typescript": true,
  "registry": {},
  "registries": {},
  "paths": {
    "ui": "src/components/ui",
    "lib": "src/lib",
    "hooks": "src/hooks",
    "styles": "src/styles",
    "icons": "src/lib/icons"
  },
  "aliases": {
    "ui": "@/components/ui",
    "lib": "@/lib",
    "hooks": "@/hooks",
    "styles": "@/styles",
    "icons": "@/lib/icons"
  },
  "app": {
    "root": ".",
    "css": "src/styles/global.css",
    "metroConfig": "metro.config.js",
    "uniwindTypes": "src/uniwind-types.d.ts"
  }
}
```

The `$schema` URL is generated from the same definitions the CLI validates against, so editor
completions cannot describe a shape the CLI would then reject.

## `paths` and `aliases` are not the same thing [#paths-and-aliases-are-not-the-same-thing]

This is the one part of the file worth understanding. They answer two different questions:

- **`paths`** — where a file lands on disk, relative to `native-components.json`.
- **`aliases`** — what other files import it as.

They coincide only when the project has path aliases configured. Many Expo apps do not, and Metro
resolves `tsconfig` paths only with `experiments.tsconfigPaths` turned on. Keeping them separate
means two things: `add` never has to parse a `tsconfig` to work out where anything went, and a
project with no aliases at all still gets imports that resolve.

<Callout title="An empty aliases object is a valid configuration">
Leave a namespace out and imports into it are written as **relative paths**, computed from where
the files actually landed. Delete `aliases` entirely and every import is relative.
</Callout>

```tsx
// aliases.ui set
import { Icon } from "@/components/ui/icon";

// aliases.ui absent
import { Icon } from "../icon";
```

`init` fills `aliases` in by reading a wildcard mapping like `"@/*": ["./src/*"]` out of
`tsconfig.json`. It never writes to that file.

### The five namespaces [#the-five-namespaces]

<TypeTable
  type={{
    ui: { type: "string", description: "Component folders. Each becomes a directory: ui/button/button.tsx.", default: "src/components/ui" },
    lib: { type: "string", description: "cn, tv, slot, and the expo/ integration helpers.", default: "src/lib" },
    hooks: { type: "string", description: "useControllableState, useThemeColor, and friends.", default: "src/hooks" },
    styles: { type: "string", description: "tokens.css, theme.css, base.css, and the Uniwind type shim.", default: "src/styles" },
    icons: { type: "string", description: "The Central Icons re-export.", default: "src/lib/icons" },
  }}
/>

## `package` [#package]

```jsonc
{ "package": { "name": "@acme/ui" } }
```

Present only when the components live in a shared package, and written by `init` when you name one.
Its presence is what makes `add` maintain the package's `exports` map and record native modules as
peers — see [Monorepos](/docs/native/cli/monorepo).

<TypeTable
  type={{
    "package.name": {
      type: "string",
      description: "The package's npm name, and therefore what the apps import components as.",
    },
  }}
/>

## `app` [#app]

Which Expo app to wire up. Every path here is relative to `app.root`, and `app.root` itself is
relative to `native-components.json`.

<TypeTable
  type={{
    root: { type: "string", description: "The Expo app root. `.` when the components live in the app itself.", default: "." },
    css: { type: "string", description: "The Tailwind entry Metro compiles.", default: "src/styles/global.css" },
    metroConfig: { type: "string", default: "metro.config.js" },
    uniwindTypes: { type: "string", description: "Where Uniwind writes its generated className types.", default: "src/uniwind-types.d.ts" },
  }}
/>

This block exists because the components and the app are not always the same package. Metro, the
Tailwind entry and the native dependencies always belong to the **app**, even when the components
live in a shared package — see [Monorepos](/docs/native/cli/monorepo).

## `registry` [#registry]

```json
{
  "registry": { "ref": "v0.2.0" }
}
```

<TypeTable
  type={{
    "registry.url": { type: "string", description: "Repository base, or a hosted registry. Defaults to this project's." },
    "registry.ref": { type: "string", description: "Git ref to read at. Defaults to the tag the CLI was published from." },
    registries: { type: "Record<string, string>", description: "Extra registries by namespace, for third-party components." },
  }}
/>

Covered in [The registry](/docs/native/cli/registry).

## `tests` [#tests]

```json
{
  "tests": { "enabled": true, "runner": "jest" }
}
```

<TypeTable
  type={{
    "tests.enabled": { type: "boolean", description: "Whether add and update copy each component's tests. init asks; --tests and --no-tests on init, add or update change it. Unset means no tests unless --tests is passed. Copying tests also adds test:ui, test:ui:unit and (on Jest) test:ui:render to package.json, keeping any you already have." },
    "tests.runner": { type: '"bun" | "jest" | "vitest"', description: "What `add --tests` writes copied suites for. Read from package.json when unset — the test script, then a vitest, jest or jest-expo dependency — and Bun when it names none." },
  }}
/>

Covered in [Tests, if you want them](/docs/native/cli/commands#tests-if-you-want-them). Changing it
rewrites each copied suite on the next `update`.

## `prefix` [#prefix]

```json
{
  "prefix": "UI"
}
```

<TypeTable
  type={{
    prefix: { type: "string", description: "What copied components call the library, in place of `DelacourUI`. A PascalCase identifier — `UI`, `Acme`." },
  }}
/>

The library brands what you see at runtime: every `displayName` (`DelacourUI.Flow.Provider`, what
React DevTools and a warning print), the tag on a thrown message (`[DelacourUI] …`) and the root
provider, `DelacourProvider`. A copy is your code, so `add` and `update` swap all three as they write —
with `"prefix": "UI"`, `UI.Flow.Provider`, `[UI] …` and `UIProvider`. `init` and `doctor` name the
provider the same way.

`init` asks for it at a terminal — `--prefix <name>` on `init` or the first `add` answers without
asking — and leaving it empty keeps the library's name. A project with no `prefix` is asked once more
by `update`.

It can change after components are copied. The next `update` renames it through every copy: an
untouched file is rewritten, an edited one is merged like any other upstream change. Your own code is
not touched — `update` lists each file of yours that still imports `DelacourProvider`, for you to
rename where your root layout mounts it.

## The lock file [#the-lock-file]

`native-components.lock.json` sits beside the config and is written by `add` and `update`, never by
you. Commit it.

```json title="native-components.lock.json"
{
  "version": 1,
  "items": {
    "button": {
      "files": {
        "ui/button/button.tsx": { "ref": "3ac4ac48…", "hash": "sha256-fa741b99…" }
      }
    }
  }
}
```

One entry per file: the registry ref it was copied from, and a hash of the text as the registry
served it — before you edited or formatted it. That pair is what
[`update`](/docs/native/cli/commands#update) merges from. The file's own text is not stored; the
registry names the library's source at a commit, so it can be fetched again from `ref`.

Tests copied with `add --tests` are recorded the same way, under the component they test. The lock is
also how `update` knows you wanted them: a component with a test in the lock has its tests kept
current, and one without is never handed any unless you pass `--tests`.

Delete the file and nothing breaks: the components work as they did, and `update` goes back to
recording whatever still matches the registry.

## `version` [#version]

```json
{
  "version": 2
}
```

<TypeTable
  type={{
    version: { type: "number", description: "The shape of this file the project was last brought up to. Written by init and update — leave it to them. Absent reads as 1." },
  }}
/>

When an option is added to this file, `version` moves with it. `update` reads the gap, asks about
each option the file predates — once — and records the new number, so a project set up by an older
CLI is never left on a default nobody chose. `doctor` warns while it is behind. See
[Updating `native-components.json`](/docs/native/cli/updating#updating-native-componentsjson).

## The rest [#the-rest]

<TypeTable
  type={{
    framework: { type: '"expo" | "react-native"', description: "Set by init from whether expo is a dependency.", default: '"expo"' },
    typescript: { type: "boolean", default: "true" },
  }}
/>

## Changing it later [#changing-it-later]

A newer CLI brings the file up to date for you: `npx delacour@latest update` asks about anything
new before it updates a component — see [Updating](/docs/native/cli/updating).

To change something yourself, edit the file and re-run `add` for anything already copied — the CLI writes to whatever `paths`
says now, so old files stay where they were. `delacour info` prints the resolved absolute paths,
which is the quickest way to check a change landed the way you meant.
