The environment object

The environment object is a record set of environment variables provided to the component through the component set.

Object definition

"env": Record<string, string>;

Usage

The easiest method for using the environment object is through object destructing into a local variable.

Read Use environment variables in your component code for more advanced examples.

export default {
  async main({}, info) {
    const { ENV_FOO, ENV_BAR } = info.env;
    return ` (1)
    <div class="container">
      <h1>My Component Context</h1>
      <p>
        The value of the first env var is ${ENV_FOO}
      </p>
      <p>
        The value of the second env var is ${ENV_BAR}
      </p>
    </div>
    `;
  }
}
1 Print a simple container with the environment variables expanded.