The `plutoLayer` helper keeps the `extends` of an app clean. It is for Pluto development, layer development, and an app that needs local layers instead of npm. A normal app does not need it.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Local Layers?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/plutocms-local-layers)
# Local layers
The `plutoLayer` helper keeps the `extends` of an app clean. It is for Pluto development, layer
development, and an app that needs local layers instead of npm. A normal app does not need it.
## Use
```ts
// nuxt.config.ts
import { plutoLayer } from '@plutocms/core/layers'
export default defineNuxtConfig({
extends: [plutoLayer('@plutocms/docs')],
})
```
`plutoLayer(name, options?)` returns the source: the local path or the package name. It has no
`install` option: Nuxt uses `install` only for a layer that it downloads from Git, and an npm
layer comes with its dependencies. Option: `root` (the folder with the checkouts; it wins over
`PLUTO_LOCAL_ROOT`).
## Files
- `layers.ts` (at the package root) — the helper. Node built-ins only (`node:fs`, `node:path`,
`node:process`). No Nuxt import, because Nuxt loads `nuxt.config.ts` before any module runs.
- `test/layers.test.ts` — the unit tests, with a temp dir of fake checkouts.
## Import path
The app imports `@plutocms/core/layers`. The package has `main: ./nuxt.config.ts` and no `exports`
field, so Node and jiti resolve a deep path to the file `layers.ts` in the package. An `exports`
field would block the other deep imports that layers and tests use, so do not add one. `.npmignore`
is a denylist, so `layers.ts` ships to npm.
With a strict package manager (pnpm), the app must list `@plutocms/core` in its own dependencies
to import the helper. With npm and Bun, the copy that a layer brings is hoisted, and the import
works.
## Rules
- Local mode is on when `PLUTO_LOCAL_ROOT` (or `options.root`) is set, unless
`PLUTO_USE_LOCAL=false`. A relative root resolves from the current working directory.
- `PLUTO_LAYER_PATHS` maps each layer (the package name without the scope) to its checkout under
the root. Two repos are monorepos: `pluto` (`core` is `pluto/packages/core`, `docs` is
`pluto/packages/layers/docs`, `3d`, `shop` and `seo` are `pluto/packages/layers/addons/<name>`) and `supabase`
(`supabase`, `supabase-shop` and `supabase-blog` are `supabase/packages/<name>`). A layer that is
not in the map has a folder of its name.
- A checkout exists when its `nuxt.config.ts` exists.
- The helper sets `PLUTO_<NAME>_PATH` (upper case, `-` to `_`; core is `PLUTO_CORE_PATH`) for each checkout that exists and
is not set yet. The `nuxt.config.ts` of each layer reads that variable, so the upstream layers go
local too.
- An explicit `PLUTO_<NAME>_PATH` always wins, in local mode and in default mode.
- When the checkout of `name` is missing, the helper returns the package name.
- A production host has no `.env`, so it uses the npm packages.