Variables
Reference for the variables available in template expressions.
Expressions can reference variables to access template input, project configuration, and runtime state. All variables are resolved on demand when first accessed, meaning variables that require network requests or user prompts have no cost unless the template actually references them.
Example
The following template greets the user by name:
{ "$schema": "https://schema.croct.com/json/v1/template.json", "title": "Greeter", "description": "Prints a greeting.", "options": { "name": { "type": "string", "description": "Your name." } }, "actions": [ { "name": "print", "message": "Hello, ${options.name}!" } ]}To apply this template, run:
npx croct@latest use template.json5 --name AliceThis prints "Hello, Alice!".
Reference
The following list describes all variables available in template expressions.
- optionsobject
The values provided for the template's defined options. Each key corresponds to an option name.
For example, if a template defines a name option, the expression ${options.name} returns the value the user provided.
- thisobject
The variables defined in the current scope via the define action. Each define action adds or updates a key in this object.
For example, after a define action sets componentPath, the expression ${this.componentPath} returns the defined value.
- packageManagerobject
Information about the detected package manager.
- namestring
The package manager in use for the project.
One of npm, yarn, pnpm, or bun.
- name
- projectobject
Information about the current project and its configuration.
- platformstring
The detected framework or platform.
One of nextjs, react, javascript, or unknown.
- pathobject
The resolved project directory paths, relative to the project root.
These values come from the paths configuration. When not explicitly set, the CLI auto-detects them based on the project structure.
- sourcestring
The source directory, for example src.
- utilitiesstring
The utilities directory, for example src/lib.
- componentsstring
The components directory, for example src/components.
- examplesstring
The examples directory, for example src/examples.
- contentstring
The content directory.
Defaults to the project root. Can be overridden in the configuration.
- source
- organizationobject
The organization associated with the project, as configured in organization.
- workspaceobject
- applicationobject
The applications associated with the project, as configured in applications. Each project has a development and a production application.
- developmentobject
- productionobject
- development
- featuresobject
The feature flags for the workspace. Each key is a boolean indicating whether the feature is enabled.
Templates can check these flags to determine if a required feature is available and provide actionable feedback when it is not.
- crossDeviceboolean
Whether cross-device tracking is enabled.
- dataExportboolean
Whether data export is enabled.
- crossDevice
- quotasobject
The resource quotas for the workspace. Each key is a number representing a limit or remaining capacity.
Templates can check remaining capacity before creating resources to warn users when they are approaching or have reached their plan limits.
- audiencesnumber
The maximum number of audiences.
- remainingAudiencesnumber
The remaining audience capacity.
- componentsnumber
The maximum number of components.
- remainingComponentsnumber
The remaining component capacity.
- slotsnumber
The maximum number of slots.
- remainingSlotsnumber
The remaining slot capacity.
- experiencesnumber
The maximum number of experiences.
- remainingExperiencesnumber
The remaining experience capacity.
- dynamicAttributesPerContentnumber
The maximum number of dynamic attributes per content.
- audiencesPerExperiencenumber
The maximum number of audiences per experience.
- audiences
- serverobject
- platform