@capgo/capacitor-env
v8.1.1
Published
Set Env var in Capacitor config and read them at runtime
Maintainers
Readme
@capgo/capacitor-env
Set Env var in Capacitor config and read them at runtime, This plugin is helpful for multitenant app or white label, when you want to keep the same code but some config have to differ.
Documentation
The most complete doc is available here: https://capgo.app/docs/plugins/env/
Install
npm install @capgo/capacitor-env
npx cap syncAPI
Capacitor plugin for accessing environment variables in native code.
This plugin provides a secure way to access environment variables that were compiled into the native application at build time. Environment variables can be configured during the build process and accessed at runtime without exposing them in the web bundle.
getKey(...)
getKey(options: { key: string; }) => Promise<{ value: string; }>Retrieves the value of a specific environment variable by key.
This method fetches environment variables that were set during the native build process. The variables must be configured in the native project before they can be accessed at runtime.
| Param | Type | Description |
| ------------- | ----------------------------- | -------------------------------------------------------------- |
| options | { key: string; } | - Configuration object containing the environment variable key |
Returns: Promise<{ value: string; }>
getPluginVersion()
getPluginVersion() => Promise<{ version: string; }>Get the version of the native Capacitor plugin.
This method returns the current version of the capacitor-env plugin that is installed in the native application. Useful for debugging and ensuring compatibility between the web and native components.
Returns: Promise<{ version: string; }>
