Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
@getverdict/envify
Advanced tools
Inject environment variables into Shopify Extensions with ease. This CLI tool simplifies the process of creating vars.tsx
or vars.jsx
files in your Shopify extension projects, especially for React-based extensions.
Because Shopify Extensions do not support environment variables currently. This leads to developers hardcoding secrets like API hosts or public keys within their apps. This practice is very disruptive for teams and as well risky because it's easy to accidentally publish development variables by accident.
With envify, you can inject these variables from your environment into a simple JavaScript/TypeScript modules and import them into your Shopify Checkout, Customer Account or POS extensions.
extensions
directory.src/vars.tsx
or src/vars.jsx
) in each valid extension subdirectory..tsx
) and JavaScript (.jsx
) output.src
folder).You can install the tool globally:
npm install -g @getverdict/envify
Or, run it directly with npx
(no installation required):
npx @getverdict/envify
Run envify
with environment variables:
envify --vars API_KEY SECRET_KEY
This will:
extensions
directory.src
folder.src/vars.jsx
(default) or src/vars.tsx
depending on --lang
.API_KEY
and SECRET_KEY
from your environment.Option | Description | Default |
---|---|---|
-f, --files | Specify custom file paths (e.g. ./env.js , ./src/vars.tsx ). | Auto-detected paths in extensions/<subdir>/src/vars.jsx or .tsx |
-v, --vars | List of environment variables to inject (e.g. API_KEY SECRET_KEY ). | None (required) |
-l, --lang | Output language: js for .jsx or ts for .tsx . | js (JavaScript) |
envify --vars API_KEY SECRET_KEY
Creates vars.jsx
in each valid subdirectory.
envify --vars API_KEY SECRET_KEY --lang ts
Creates vars.tsx
files instead of vars.jsx
.
envify --files ./env.js ./config/vars.tsx --vars API_KEY SECRET_KEY
Writes to the specified files instead of using extensions
.
Given:
envify --vars API_KEY SECRET_KEY --lang ts
export API_KEY="my-api-key"
export SECRET_KEY="my-secret-key"
src/vars.tsx
will be:
// This file is auto-generated by envify
export const API_KEY = "my-api-key";
export const SECRET_KEY = "my-secret-key";
Then you can simply import the module into your React components:
import { API_KEY } from "./vars";
// rest of your Checkout UI Extension code
.envify.json
for ConfigurationYou can provide default configuration values in a .envify.json
file located in your project's root directory. This file allows you to specify which files to write and which environment variables to include without needing to pass them via CLI options every time.
.envify.json
{
"files": ["./env.js", "./config/vars.tsx"],
"vars": ["API_KEY", "SECRET_KEY", "ANALYTICS_ID"]
}
--files
option, Envify will look at the files
field in .envify.json
.--vars
option, Envify will use the vars
field from .envify.json
.If both .envify.json
and CLI options are provided, the CLI options will take precedence.
If you've defined your configuration in .envify.json
, you can simply run:
envify
Envify will read the configuration from .envify.json
and write your environment variables to the specified files.
If no .envify.json
is found, Envify will revert to its default behavior, which involves searching the extensions
directory and requiring you to provide --vars
via the CLI.
No --vars
provided:
envify --vars
Error: At least one environment variable must be provided using --vars.
No valid subdirectories with src
:
Error: No valid subdirectories with "src" folders found in "extensions".
Missing extensions
directory:
Error: "extensions" directory not found.
Q: What if an environment variable isn't set?
A: A warning is logged and the variable appears with an empty value.
Q: Can I use this for non-React extensions?
A: By default, it only processes subdirectories with src
. Use --files
for custom paths if needed.
Q: Can I use this in CI/CD?
A: Yes. Ensure the required variables are set in your pipeline’s environment.
git clone https://github.com/getverdict/envify.git
cd envify
npm install
npm link
envify --vars API_KEY SECRET_KEY
Contributions are welcome! Please submit issues or pull requests.
FAQs
Environment variables for your Shopify Extensions
The npm package @getverdict/envify receives a total of 1 weekly downloads. As such, @getverdict/envify popularity was classified as not popular.
We found that @getverdict/envify demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.