# Environment Configuration

Configure your environment variables to customize MindedJS behavior and connect to external services.

## Environment Variables

Create a `.env` file in your project root to configure MindedJS:

```bash
# .env file
```

#### `BROWSER_TASK_MODE`

Controls the mode in which the browser task runs.

```bash
BROWSER_TASK_MODE=cloud
```

* **`onPrem`**: Browser task runs on the customer's own infrastructure with a remotely installed on-premise kit.
* **`localRun`**: Browser task runs locally where the SDK is running. Requires configuring a UV project and installing dependencies.
* **`cloud`**: Browser task runs on the Minded platform. This is the default mode.

### Platform Connection

#### `MINDED_CONNECTION_TOKEN`

Required to connect to the Minded platform for advanced features and monitoring. Each token is specific to the agent you are working on.

```bash
MINDED_CONNECTION_TOKEN=your-minded-connection-token
```

{% hint style="info" %}
Your connection token is available on the [Minded platform](https://app.minded.com) in the agent page within the GitHub integration popup. You can also use the npx command provided there to automatically set the minded token.
{% endhint %}

## Example .env File

Here's a complete example of a `.env` file:

```bash
# Core Configuration

# Platform Connection
MINDED_CONNECTION_TOKEN=your-minded-connection-token-here
```

## Loading Environment Variables

MindedJS automatically loads environment variables from your `.env` file. Make sure to:

1. Create the `.env` file in your project root
2. Add `.env` to your `.gitignore` file to keep credentials secure
3. Never commit your `.env` file to version control

```bash
# Add to .gitignore
.env
```

## Runtime Environment Detection

MindedJS uses specific environment variables to determine the runtime environment and adjust behavior accordingly.

### Environment Variables

| Environment        | NODE\_ENV     | MINDED\_CLOUD | Description                          |
| ------------------ | ------------- | ------------- | ------------------------------------ |
| Local Development  | `development` | `false`       | Running locally on developer machine |
| Minded Platform    | `development` | `true`        | Running in Minded platform sandbox   |
| Staging Service    | `staging`     | `true`        | Agent deployed as staging service    |
| Production Service | `production`  | `true`        | Agent deployed as production service |

### Usage in Code

```typescript
// Check if running on Minded Cloud
if (process.env.MINDED_CLOUD === 'true') {
  // Running on Minded infrastructure (dev/staging/prod)
  logger.info({ message: 'Running on Minded Cloud' });
}

// Check specific environment
if (process.env.NODE_ENV === 'production' && process.env.MINDED_CLOUD === 'true') {
  // Production environment on Minded Cloud
  logger.info({ message: 'Production mode' });
}
```

### Environment-Specific Behavior

```typescript
const isDevelopment = process.env.NODE_ENV === 'development';
const isMindedCloud = process.env.MINDED_CLOUD === 'true';

// Enable debug features only in development
if (isDevelopment) {
  // Enable verbose logging
  logger.setLevel('debug');
}

// Use different endpoints based on environment
const apiEndpoint = isMindedCloud ? 'https://api.minded.com' : 'http://localhost:3000';
```

## Next Steps

With your environment configured, continue to:

1. [Project Configuration](https://docs.minded.com/getting-started/project-configuration) - Set up your `minded.json` file
2. [Quick Start](https://docs.minded.com/getting-started/quick-start) - Build your first agent
