# \[Feature request\] Document support for environment variables

**URL:** <https://community.shopify.dev/t/feature-request-document-support-for-environment-variables/6401>\
**Category:** Extensions\
**Tags:** checkout-ui-ext\
**Created:** [January 20, 2025, 9:01pm UTC](https://community.shopify.dev/t/feature-request-document-support-for-environment-variables/6401 "2025-01-20T21:01:16Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![edhgoose](https://sea1.discourse-cdn.com/shopifycommunity/user_avatar/community.shopify.dev/edhgoose/32/2800_2.png) [@edhgoose](https://community.shopify.dev/u/edhgoose)\
**Post date:** [January 20, 2025, 9:01pm UTC](https://community.shopify.dev/t/feature-request-document-support-for-environment-variables/6401/1 "2025-01-20T21:01:16Z")

</div>

_As requested in [https://github.com/Shopify/ui-extensions/issues/2521](https://github.com/Shopify/ui-extensions/issues/2521), I am re-raising this issue._

_Please find below the details of [https://github.com/Shopify/ui-extensions/issues/680](https://github.com/Shopify/ui-extensions/issues/680)_

## Please list the related package(s)

checkout-ui-extension

## Is your feature request related to a problem? Please describe.

App that my team develops is deployed to multiple environments (dev, sandbox, staging, prod, etc).

Whenever, I am deploying app to these environments process becomes very manual.

For each environment I need to go and select the different app and then run deploy command.

Also, inside my extension code, api endpoint will change depending upon the environment.

Whenever, I run `yarn dev` for a particular app, I need to go in extension code and change the api endpoint manually. It would be wonderful if you can provide .env file and we can set env vars for `shopify app dev` and `shopify app deploy’ commands in the .env file.

Support passing the environment variables to checkout extensions. It is needed if the extension is built for multiple environments and use different APIs.

## Describe the changes you are looking for

Ability to pass custom options to `shopify app dev` and `shopify app deploy`, it could be using either .env file or separate key-value pairs. These environment variables should flow to the checkout extension code and it should be made available to use.

## Describe alternatives you’ve considered

Let’s say extension is deployed on 3 environments `dev`, `sandbox`, and `prod`. For each of these envs checkout extension would want to hit different url `dev.mydomain.com`, `sandbox.mydomain.com`, etc.

But whenever app is deployed, I can’t really specify which env to target.

To achieve this I have defined extension settings, whenever app is deployed I can get value for env from extension settings.

But extension settings are not available when running local dev server. So whenever I run the local dev server, I’ve to go and update the env code. It is really frustrating.

## Additional context

Various people have implemented hacks - but first party support would be extremely helpful.

---

<div class="post-metadata">

**Author:** ![Tomoyuki\_Kashiro](https://sea1.discourse-cdn.com/shopifycommunity/user_avatar/community.shopify.dev/tomoyuki_kashiro/32/2911_2.png) [@Tomoyuki\_Kashiro](https://community.shopify.dev/u/Tomoyuki_Kashiro)\
**Post date:** [January 31, 2025, 9:02am UTC](https://community.shopify.dev/t/feature-request-document-support-for-environment-variables/6401/2 "2025-01-31T09:02:24Z")

</div>

For remix server, remix doesn’t support multiple environment variables, only support `.env` file for local development to override variables.

> **[Environment Variables | Remix](https://remix.run/docs/en/main/guides/envvars)**

so you need define environment variables in each servers.

- local development : `.env`
- other environment : set variables to each server

on the other hand, app extension has a solution to load environment variables.

- `npm run shopify app deploy -- -c sandbox` uses `shopify.app.sandbox.toml` and `.env.sandbox`
- `npm run shopify app deploy -- -c production` uses `shopify.app.production.toml` and `.env.production`

Hope this helps 🙂

---

<div class="post-metadata">

**Author:** ![edhgoose](https://sea1.discourse-cdn.com/shopifycommunity/user_avatar/community.shopify.dev/edhgoose/32/2800_2.png) [@edhgoose](https://community.shopify.dev/u/edhgoose)\
**Post date:** [January 31, 2025, 9:34am UTC](https://community.shopify.dev/t/feature-request-document-support-for-environment-variables/6401/3 "2025-01-31T09:34:02Z")

</div>

Hi @Tomoyuki_Kashiro - this post is about Checkout Extensions. I don’t think this has anything to do with Remix.

Specifically, I’m interested in how to access those environment variables in the deployed checkout extension. I don’t believe there’s a way to do that in the locked down environment of Checkout Extensions.

Do you think there is a way to access those variables?

---

<div class="post-metadata">

**Author:** ![Tomoyuki\_Kashiro](https://sea1.discourse-cdn.com/shopifycommunity/user_avatar/community.shopify.dev/tomoyuki_kashiro/32/2911_2.png) [@Tomoyuki\_Kashiro](https://community.shopify.dev/u/Tomoyuki_Kashiro)\
**Post date:** [January 31, 2025, 11:46pm UTC](https://community.shopify.dev/t/feature-request-document-support-for-environment-variables/6401/4 "2025-01-31T23:46:32Z")

</div>

@edhgoose

The second half of my reply is about checkout extension.  
Give it a try 🙂

> [@Tomoyuki\_Kashiro](#):
>
> on the other hand, app extension has a solution to load environment variables.
> 
> - `npm run shopify app deploy -- -c sandbox` uses `shopify.app.sandbox.toml` and `.env.sandbox`
> - `npm run shopify app deploy -- -c production` uses `shopify.app.production.toml` and `.env.production`

---

<div class="post-metadata">

**Author:** ![edhgoose](https://sea1.discourse-cdn.com/shopifycommunity/user_avatar/community.shopify.dev/edhgoose/32/2800_2.png) [@edhgoose](https://community.shopify.dev/u/edhgoose)\
**Post date:** [February 1, 2025, 12:33am UTC](https://community.shopify.dev/t/feature-request-document-support-for-environment-variables/6401/5 "2025-02-01T00:33:44Z")

</div>

@Tomoyuki_Kashiro - thanks, but how do you access the environment variable from the running code in the Shopify Extension?

---

<div class="post-metadata">

**Author:** ![Tomoyuki\_Kashiro](https://sea1.discourse-cdn.com/shopifycommunity/user_avatar/community.shopify.dev/tomoyuki_kashiro/32/2911_2.png) [@Tomoyuki\_Kashiro](https://community.shopify.dev/u/Tomoyuki_Kashiro)\
**Post date:** [February 1, 2025, 1:42am UTC](https://community.shopify.dev/t/feature-request-document-support-for-environment-variables/6401/6 "2025-02-01T01:42:53Z")

</div>

@edhgoose

The checkout extension building process uses [esbuild’s define option](https://esbuild.github.io/api/#define) under the hood.

.env.sandbox

```auto
foo=bar

```

in checkout extension code

```js
console.log(process.env.foo)

```

build

```bash
$ npm run shopify app deploy -- -c sandbox

```

the checkout extension code will be replaced `.env.sandbox` values.

```js
console.log("bar")

```

> you also need setup shopify.app.sandbox.toml.

---

<div class="post-metadata">

**Author:** ![edhgoose](https://sea1.discourse-cdn.com/shopifycommunity/user_avatar/community.shopify.dev/edhgoose/32/2800_2.png) [@edhgoose](https://community.shopify.dev/u/edhgoose)\
**Post date:** [February 2, 2025, 7:49pm UTC](https://community.shopify.dev/t/feature-request-document-support-for-environment-variables/6401/7 "2025-02-02T19:49:35Z")

</div>

Well, colour me surprised. It does indeed work.

Critically, `console.log(process.env)` will _not_ work, but `console.log(process.env.WHATEVER)` where `WHATEVER` is defined in your `.env` file does indeed work.

In that case - my ask of the Shopify team would be to document that behaviour. I will adjust my topic accordingly.

Thank you @Tomoyuki_Kashiro - really appreciate it.

---

<div class="post-metadata">

**Author:** ![Dylan](https://sea1.discourse-cdn.com/shopifycommunity/user_avatar/community.shopify.dev/dylan/32/90_2.png) [@Dylan](https://community.shopify.dev/u/Dylan)\
**Post date:** [February 3, 2025, 2:46pm UTC](https://community.shopify.dev/t/feature-request-document-support-for-environment-variables/6401/8 "2025-02-03T14:46:44Z")

</div>

This is my own workaround for the missing ENV variable support in Checkout UI / POS extensions:

> [@CLI tool for Environment Variables in Checkout Extensions](https://community.shopify.dev/t/cli-tool-for-environment-variables-in-checkout-extensions/4469):
>
> Hi all, Had some extra time today and decided to release a tool I’ve written to help with the missing ENV variable functionality in Extensions. Why? Without environment variables, developers need to hardcode secrets like API hosts, or public keys. This is accident prone and doesn’t scale well with teams. One accidental development variable being published can actually break your merchant’s checkouts for example. Usage envify shims environment variables into your Shopify Extensions. For examp…

In short, this CLI tool reads your current environment can creates a shimmed variables file that is read by your extension. Then in your CI/CD you can run this same tool to replace the config file with your production ENV variables:

```auto
npx @getverdict/envify --vars API_HOST

```

---

<div class="post-metadata">

**Author:** ![dac514](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@dac514](https://community.shopify.dev/u/dac514)\
**Post date:** [March 13, 2026, 8:05pm UTC](https://community.shopify.dev/t/feature-request-document-support-for-environment-variables/6401/9 "2026-03-13T20:05:30Z")

</div>

> [@edhgoose](#):
>
> In that case - my ask of the Shopify team would be to document that behaviour.

Bump.

[Source code confirms it](https://github.com/Shopify/cli/blob/c0efc0f098a2d5fbe3095f05068bd0dc3515c24e/packages/app/src/cli/services/extensions/bundle.test.ts#L110): Vars like `process.env.X` will be substituted by **esbuild define** , but only if a [matching config](https://github.com/Shopify/cli/blob/c0efc0f098a2d5fbe3095f05068bd0dc3515c24e/packages/app/src/cli/models/app/loader.ts#L395) can be found.

Had I known `shopify app deploy` uses both `shopify.app.YOURNAME.toml` and `.env.YOURNAME` I could have avoided a couple days of playing Yakety Sax / The Benny Hill theme song if this were documented somewhere. MCP finds nothing?
