# Environment variables

> The LIT_PLUGIN_* variables: what each one maps to, how values are parsed, and which options have none.

Every option except the three below also resolves from an environment variable with the `LIT_PLUGIN` prefix. Use them to switch dev-only tooling on per machine without editing `vite.config.ts`.

| Env var                                 | Maps to                    |
| --------------------------------------- | -------------------------- |
| `LIT_PLUGIN_HMR`                        | `hmr.enabled`              |
| `LIT_PLUGIN_HMR_RECONNECT`              | `hmr.reconnect`            |
| `LIT_PLUGIN_HMR_PRIVATE_FIELDS`         | `hmr.privateFields`        |
| `LIT_PLUGIN_HMR_CHILD_STATE`            | `hmr.childState`           |
| `LIT_PLUGIN_HMR_ON_INCOMPATIBLE`        | `hmr.onIncompatible`       |
| `LIT_PLUGIN_HMR_INDICATOR`              | `hmr.indicator.enabled`    |
| `LIT_PLUGIN_HMR_INDICATOR_COUNT`        | `hmr.indicator.count`      |
| `LIT_PLUGIN_SOURCE_OVERLAY`             | `sourceOverlay` (enable)   |
| `LIT_PLUGIN_SOURCE_OVERLAY_KEY`         | `sourceOverlay.key`        |
| `LIT_PLUGIN_SOURCE_OVERLAY_EDITOR`      | `sourceOverlay.editor`     |
| `LIT_PLUGIN_SOURCE_OVERLAY_THROTTLE_MS` | `sourceOverlay.throttleMs` |
| `LIT_PLUGIN_TIMELINE`                   | `timeline` (enable)        |
| `LIT_PLUGIN_CSS_SHEET_BUILD`            | `cssSheetBuild`            |
| `LIT_PLUGIN_DEVTOOLS_WORKSPACE`         | `devtoolsWorkspace`        |

## Precedence

Per setting, the value passed to `litPlugin()` wins over the environment variable, which wins over the built-in default.

Precedence applies to each setting on its own, not to the group it sits in. So `litPlugin({hmr: {reconnect: true}})` fixes `reconnect`, and `LIT_PLUGIN_HMR_INDICATOR_COUNT=1` still reaches the indicator.

A live override from the DevTools **Settings** tab sits above all three, for the settings it can change. The tab labels a value set by env or an option with its layer, such as `Zed (env)`; a built-in default carries no label. While an override is active the row names the value it replaced, such as `env: Zed`, so you can tell what a reset restores.

## How values are parsed

* **Booleans** accept `true`, `1`, `false`, and `0`. Any other value counts as unset, and the option falls through to its default.
* **Numbers** must parse as a number. `LIT_PLUGIN_SOURCE_OVERLAY_THROTTLE_MS` is the only one. An unparsable value counts as unset.
* **`LIT_PLUGIN_CSS_SHEET_BUILD`** is checked against the four allowed values. Anything else logs a warning and falls back to the default.
* **`LIT_PLUGIN_SOURCE_OVERLAY_EDITOR`** must name a built-in editor: `vscode`, `cursor`, `zed`, `idea` or `windsurf`. Anything else logs a warning and falls back to the default. A custom editor object can only be passed as the `sourceOverlay.editor` option.
* **`LIT_PLUGIN_DEVTOOLS_WORKSPACE`** takes a boolean to turn the workspace reply on or off. Any other value is the folder to serve, relative to Vite’s `root`.

## Options with no environment variable

Three options are config-only. `sourceOverlay.exclude` and `sourceOverlay.onSelect` are functions, and `sourceOverlay.workspaceRoot` is a path that belongs next to the rest of your build config.

## Example

```ini
# Dev-only tooling, switched on without touching vite.config.ts.
LIT_PLUGIN_TIMELINE=true
LIT_PLUGIN_SOURCE_OVERLAY=true
LIT_PLUGIN_SOURCE_OVERLAY_EDITOR=zed
LIT_PLUGIN_SOURCE_OVERLAY_THROTTLE_MS=16
LIT_PLUGIN_HMR_INDICATOR_COUNT=1
```

The plugin reads these through Vite’s `loadEnv`, so they follow Vite’s usual `.env` resolution: `.env`, `.env.local`, and the mode-specific variants.

Restart after an edit

The values are read once, at config time. Restart the dev server after you edit a `.env` file, or the old values stay in effect.

## Related

[Options](/reference/options/)The same surface as a config object, with defaults.

[Open a component in your editor](/guides/source-overlay/)The feature with the most env-configurable sub-options.
