Fallback content

Learn how the CLI manages fallback content for your project.

The CLI downloads the default content for each configured slot, version, and locale. This content is made available to the SDK as automatic fallback, so your application always has content to render even when dynamic content is unavailable.

How it works

Every time you add, remove, install, update, or upgrade slots, the CLI fetches the default content from your workspace for every slot, version, and locale combination listed in the configuration file and stores it locally.

The SDK then uses this content as a safety net. For example, in JavaScript projects the content is stored in the @croct/content package with per-slot files organized by locale. You can also access this content directly using the functions in the @croct/content package.

Fallback hierarchy

When the SDK resolves content for a slot, it follows this priority order:

  1. Dynamic content: personalized or targeted content from the API
  2. Explicit fallback: a fallback value provided directly in your code
  3. Default content: the content downloaded and managed by the CLI
  4. Error: if none of the above are available, the request fails

The CLI-managed default content ensures your application renders meaningful content even during network failures or service disruptions.

Synchronization

The install command re-downloads all default content. The CLI can register a postinstall hook to keep content in sync automatically whenever dependencies are installed.

You can also run update to re-download content without changing any version specifiers. If you want to move to a newer major version, use upgrade instead, which updates the version specifiers in the configuration file and then re-downloads content accordingly.