Skip to main content
@capgo/capacitor-env Developer Tools Open source

Env Capacitor plugin

Securely manage environment variables and configuration across different build environments

Install

bun add @capgo/capacitor-env bunx cap sync
npm, pnpm or yarn
  • npm install @capgo/capacitor-env
  • pnpm add @capgo/capacitor-env
  • yarn add @capgo/capacitor-env

Guide

How to use Env in Capacitor

Using @capgo/capacitor-env

Capacitor plugin for accessing environment variables in native code.

Install

bun add @capgo/capacitor-env
bunx cap sync

bunx cap sync copies the plugin's native code into your native projects. Run it again after every plugin upgrade.

Import

import { Env } from '@capgo/capacitor-env';

API at a glance

Method Description
getKey Retrieves the value of a specific environment variable by key.

Examples

getKey()

Retrieves the value of a specific environment variable by key.

import { Env } from '@capgo/capacitor-env';

const result = await Env.getKey({ key: 'API_URL' });
console.log(result.value); // 'https://api.example.com'

Full reference

Keep going from Using @capgo/capacitor-env

If you are using Using @capgo/capacitor-env to plan native plugin work, connect it with @capgo/capacitor-env for the implementation detail in @capgo/capacitor-env, Getting Started for the implementation detail in Getting Started, Capgo Plugin Directory for the product workflow in Capgo Plugin Directory, Capacitor Plugins by Capgo for the implementation detail in Capacitor Plugins by Capgo, and Adding or Updating Plugins for the implementation detail in Adding or Updating Plugins.

FAQ

Env plugin FAQ

How do I install the Env plugin in a Capacitor app?

Run "bun add @capgo/capacitor-env" (or "npm install @capgo/capacitor-env"), then run "bunx cap sync" so the iOS and Android projects pick up the native code. Import it from "@capgo/capacitor-env" in your app code.

Does @capgo/capacitor-env work with React, Vue and Angular?

Yes. Env is a Capacitor package, so it works with any web framework that runs inside Capacitor, including Ionic, React, Vue, Angular, Svelte and plain JavaScript.

Which Capacitor version does @capgo/capacitor-env support?

Capgo plugins follow Capacitor's major version: use the plugin major version that matches your Capacitor major version (for example plugin v8 with Capacitor 8). The compatibility table in the GitHub README lists the maintained versions.

Is @capgo/capacitor-env free and open source?

Yes. The source code is public on GitHub at https://github.com/Cap-go/capacitor-env/ and the package is free to install from npm. Bug reports and pull requests are welcome.

Can I update code that uses Env without an App Store review?

Installing or upgrading the plugin changes native code, so it needs a new store build. After that, JavaScript, HTML and CSS changes that call the plugin can ship instantly with Capgo live updates.

Ship Env changes without waiting for app review

Once the plugin is in your store build, Capgo live updates push your JavaScript, HTML and CSS changes to users in minutes.

Start with Capgo