# Variables

Reference for the variables available in template expressions.

[Expressions](/reference/cli/templates/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:

**template.json5**

```json5
{
  "$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:

```sh
croct use template.json5 --name Alice
```

This prints "Hello, Alice!".

## Reference

The following list describes all variables available in template expressions.

- `options`: `object`

  The values provided for the template's defined [options](/reference/cli/templates/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.

- `this`: `object`

  The variables defined in the current scope via the [`define`](/reference/cli/templates/actions/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.

- `packageManager`: `object`

  Information about the detected package manager.

  - `name`: `string`

    The package manager in use for the project.

    One of `npm`, `yarn`, `pnpm`, or `bun`.

- `project`: `object`

  Information about the current project and its configuration.

  - `platform`: `string`

    The detected framework or platform.

    One of `nextjs`, `react`, `javascript`, or `unknown`.

  - `path`: `object`

    The resolved project directory paths, relative to the project root.

    These values come from the [`paths`](/reference/cli/configuration#paths-prop) configuration. When not explicitly set, the CLI auto-detects them based on the project structure.

    - `source`: `string`

      The source directory, for example `src`.

    - `utilities`: `string`

      The utilities directory, for example `src/lib`.

    - `components`: `string`

      The components directory, for example `src/components`.

    - `examples`: `string`

      The examples directory, for example `src/examples`.

    - `content`: `string`

      The content directory.

      Defaults to the project root. Can be overridden in the [configuration](/reference/cli/configuration#paths-content-prop).

  - `organization`: `object`

    The organization associated with the project, as configured in [`organization`](/reference/cli/configuration#organization-prop).

    - `slug`: `string`

      The organization identifier, for example `acme`.

    - `url`: `string`

      The URL to the organization in the dashboard, for example `https://app.croct.com/organizations/acme`.

  - `workspace`: `object`

    The workspace associated with the project, as configured in [`workspace`](/reference/cli/configuration#workspace-prop).

    - `slug`: `string`

      The workspace identifier, for example `default`.

    - `url`: `string`

      The URL to the workspace in the dashboard, for example `https://app.croct.com/organizations/acme/workspaces/default`.

  - `application`: `object`

    The applications associated with the project, as configured in [`applications`](/reference/cli/configuration#applications-prop). Each project has a development and a production application.

    - `development`: `object`

      The development application.

      - `slug`: `string`

        The application identifier, for example `my-app-dev`.

      - `url`: `string`

        The URL to the application in the dashboard.

      - `publicId`: `string`

        The public ID used to initialize the SDK, for example `00000000-0000-0000-0000-000000000000`.

    - `production`: `object`

      The production application.

      - `slug`: `string`

        The application identifier, for example `my-app`.

      - `url`: `string`

        The URL to the application in the dashboard.

      - `publicId`: `string`

        The public ID used to initialize the SDK.

  - `features`: `object`

    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.

    - `crossDevice`: `boolean`

      Whether cross-device tracking is enabled.

    - `dataExport`: `boolean`

      Whether data export is enabled.

  - `quotas`: `object`

    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.

    - `audiences`: `number`

      The maximum number of audiences.

    - `remainingAudiences`: `number`

      The remaining audience capacity.

    - `components`: `number`

      The maximum number of components.

    - `remainingComponents`: `number`

      The remaining component capacity.

    - `slots`: `number`

      The maximum number of slots.

    - `remainingSlots`: `number`

      The remaining slot capacity.

    - `experiences`: `number`

      The maximum number of experiences.

    - `remainingExperiences`: `number`

      The remaining experience capacity.

    - `dynamicAttributesPerContent`: `number`

      The maximum number of dynamic attributes per content.

    - `audiencesPerExperience`: `number`

      The maximum number of audiences per experience.

  - `server`: `object`

    The local development server state.

    - `running`: `boolean`

      Whether the development server is currently running.

    - `url`: `string` (optional)

      The server URL, for example `http://localhost:3000`.

      Only available when the server is running.

## Explore

- [Expressions](/reference/cli/templates/expressions): Learn how to use dynamic values in templates.
- [Actions](/reference/cli/templates/actions): Browse all available template actions.
