CLI
You changed a block's props and the site editor still shows the old form: the schema needs regenerating. This page lists every deco command and its flags.
The Deco CLI is the deco command. It ships inside @decocms/blocks, so there's nothing extra to install, and it always matches your runtime version. Run it once with npx (bunx works the same):
npx @decocms/blocks schemaOnce @decocms/blocks is installed, your package.json scripts call it by its short name, deco (for example deco schema). To call it from your own code, import it from @decocms/blocks/cli.
Every command works on one folder, .deco/, in your app root (the folder with your app's package.json). Which file in it is which, and which to commit, is in The .deco folder.
It has four commands, and each does one job:
deco schematurns the types in.deco/index.tsinto.deco/schema.gen.json. Commit this file. See Forms from types.deco contentturns the files in.deco/blocksinto the content module,.deco/blocks.gen.ts. It's generated, so gitignore it. See The content module.deco checkmakes sure your saved blocks fit your code, and fails if one doesn't. It writes nothing. See Checking content.deco serveis the local server the site editor uses to edit the files on your machine. Run it inside your site's git repository. See Edit on your machine.
There's no deco publish: publishing is committing. Running it prints that and exits with code 1 (see Design decisions).
Run it before dev and build
There's no separate dev command: run deco schema and deco content before your dev server and your build. The build also runs deco check, so content that doesn't fit the code fails the deploy instead of shipping; dev skips it, so a content error doesn't stop your dev server.
{
"scripts": {
"predev": "deco schema && deco content",
"prebuild": "deco schema && deco content && deco check"
}
}Finding the .deco folder
Every command takes --root <dir>: the folder that contains .deco/, relative to the current folder. You rarely pass it. By default, the command walks up from the current folder to the first folder with a .deco/, so it works from any subfolder of your app.
If no folder on the way up has a .deco/, the command stops with an error:
no .deco/ found from /path/you/ran/it/in; run inside your app or pass --rootIn a monorepo, walking up from the repository root never reaches apps/storefront/.deco, so the command fails there (or, if the root has a stray .deco/, it uses that one). Run the commands inside the app instead, for example as scripts in apps/storefront/package.json. Then @decocms/blocks must be a dependency of that app, so its scripts can find deco. Or pass the app from the repository root:
deco schema --root apps/storefront
deco content --root apps/storefrontThe site editor's "app root" setting points at that same folder, both on your machine and when the site editor reads your repository on GitHub in the hosted version.
deco schema and deco content
deco schema [--root <dir>] [--watch]
deco content [--root <dir>] [--watch]| Command | Reads | Writes |
|---|---|---|
deco schema | .deco/index.ts (or .deco/index.tsx) | .deco/schema.gen.json |
deco content | .deco/blocks/ | .deco/blocks.gen.ts |
deco content only bundles the JSON files in .deco/blocks. It never reads your block map.
The options:
--root <dir>: the folder that contains.deco/(see above).--watch: regenerate as files change.
deco check
deco check [--root <dir>]deco check reads .deco/schema.gen.json and .deco/blocks as they are, writes nothing, and validates every saved block against that schema. It doesn't generate the schema or load your TypeScript, so run deco schema first: deco schema && deco check. It exits with 0 when everything fits, and with 1 otherwise, listing the problems per file. Warnings are listed but don't change the exit code. What it checks, and how to run it on every pull request, is in Checking content.
deco serve
deco serve [--root <dir>] [--port <n>] [--host <addr>] [--preview <host:port|url>] [--assets <dir>] [--read-only]deco serve is the local server the site editor uses to edit the files on your machine, over the content protocol: it reads and writes .deco/blocks, reads .deco/schema.gen.json, and accepts uploads into public/assets/ (or --assets). It tells the site editor which root it serves through the content protocol's describe. The flow is in Edit on your machine.
Run it inside your site's git repository, and have git installed. The site editor shows what you changed since your last commit, and deco serve reads that commit (HEAD) with git; it never commits or stages anything. Discarding a change in the site editor puts that block back as it is in HEAD, both the file and, since 8.2.1, git's index: if you had staged the change it's unstaged, and a block you'd staged as new is taken out of the index and deleted. Other files you've staged aren't touched. Its startup output says what it compares with, such as Changes compared with main (1a2b3c4), or no commits yet in a new repository. Otherwise it doesn't start, and exits with code 1:
| It prints | What to do |
|---|---|
deco serve runs inside your site's git repository, and <root> isn't in one. Run it in the folder where you cloned the site, or run git init there first, then start deco serve again. | Run it in the folder where you cloned the site. For a site that isn't in git yet, run git init in it first; with no commits, every saved block shows as a change. |
deco serve needs git, and it isn't installed here. Install git (https://git-scm.com/downloads), then run deco serve again inside your site's git repository. | Install git, then start deco serve again. |
deco serve couldn't use the git repository at <root>: … | git refused the repository; the rest of the line is git's own message, such as a "dubious ownership" warning. Fix what it says and start deco serve again. |
deco schema, deco content and deco check don't need git.
deco serve takes:
--root <dir>: the folder that contains.deco/, such asapps/storefrontin a monorepo. By default, it walks up from the current folder to the first folder with a.deco/, like every command.--port <n>: the port to listen on (default 4545).--host <addr>: the address to listen on. By default the server listens on loopback, both 127.0.0.1 and ::1 on the same port, sohttp://localhost:<port>reaches it whichever address your system giveslocalhost; it prints its address aslocalhost. With--hostit listens on that one address only. An address beyond loopback prints a warning: the server has no authentication, so other machines on your network can then read and write your content. The site editor still connects only throughlocalhost: with0.0.0.0the printed link useslocalhost, and with a specific network address the link doesn't work. How the server is protected is in The local server.--preview <host:port|url>: your running dev app, which the site editor shows in its Preview tab, aslocalhost:8001or a full URL such ashttp://127.0.0.1:3000/en/. It must be on your machine (localhost,127.0.0.1or::1). By default, theserver.portfrom your Vite config (read as text, never run), elsehttp://localhost:5173. The server prints it asPreviewand reports it indescribe(see The methods).--assets <dir>: the folder the site editor's uploads are written to, relative to the folder that contains.deco(defaultpublic/assets). The field always stores/assets/<name>, whatever this folder is, so a folder you pass must be served at/assets/; see Images and other uploads.--read-only: serve the content without accepting writes or uploads.
deco serve has no authentication and answers any website. Any page open in your browser can read and write your content through it, so run it only while you're editing and stop it when you're done. --host also exposes it to your network.