native-components.json

Where components go, how they import each other, and which app to wire up.

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

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

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.

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.

// 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

Prop

Type

package

{ "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.

Prop

Type

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.

Prop

Type

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.

registry

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

Prop

Type

Covered in The registry.

tests

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

Prop

Type

Covered in Tests, if you want them. Changing it rewrites each copied suite on the next update.

prefix

{
  "prefix": "UI"
}

Prop

Type

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

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

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 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": 2
}

Prop

Type

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.

The rest

Prop

Type

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.

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.

On this page