> ## Documentation Index
> Fetch the complete documentation index at: https://docs.goldsky.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Environment variables (env)

There are two ways to expose values to your tasks: the `env` field in your [App Configuration](../app-configuration) and
[Secrets](../secrets). Both show up on the `env` property of your task context at runtime.

Only the values for the current environment are injected — when running locally, only `env.local` values are used; when deployed, only `env.cloud` values are used. They are never merged together.

If a secret has the same name as an env variable, the secret value takes precedence.

## Example

Declare environment variables and secrets in your compose.yaml:

```yaml theme={null}
# compose.yaml
name: "my-app"
env:
  local:
    MY_VAR: "foo"
    ANOTHER_VAR: "bar"
  cloud:
    MY_VAR: "boo"
    ANOTHER_VAR: "baz"
secrets:
  - MY_SECRET
tasks:
 - name: "task1"
   path: "./task1.ts"
```

Secrets are listed by name only — set their values locally in a `.env` file or in the cloud with `goldsky compose secrets set`. See [Secrets](../secrets) for details.

Reference them in your tasks via the `env` property of the task context:

```typescript theme={null}
import { TaskContext } from "compose";

export async function main({ env }: TaskContext) {
  console.log(env.MY_VAR);
  console.log(env.ANOTHER_VAR);
  console.log(env.MY_SECRET);
}
```

<CardGroup cols={2}>
  <Card title="callTask" icon="code" href="./call-task">
    Trigger tasks from other tasks, creating composable workflows.
  </Card>

  <Card title="Using Packages" icon="file-code" href="./packages">
    You can use any sandbox compatible typescript packages with any package manager.
  </Card>
</CardGroup>
