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.