secure-env-vault-react-native-sdk
v0.1.3
Published
[](https://www.npmjs.com/package/secure-env-vault-react-native-sdk) [](https://www.npmjs
Readme
secure-env-vault-react-native-sdk
React Native SDK for secure-env-vault.
Install
npm install secure-env-vault-react-native-sdk
# or
yarn add secure-env-vault-react-native-sdkUsage
1. Create a .env.vault file
Use the CLI to encrypt your secrets:
npx secure-env enc .env .env.vault <password>2. Load and decrypt secrets in your app
A. Auto-detect vault file (recommended)
If you place .env.vault.json in your project root, you can call loadVault without specifying the vault:
import { loadVault, getSecret } from "@secure-env-vault/react-native-sdk";
// Will auto-detect .env.vault.json in the project root
loadVault(undefined, "your-password");
console.log(getSecret("API_KEY"));B. Specify the vault file manually
import { loadVault, getSecret } from "@secure-env-vault/react-native-sdk";
import vault from "./.env.vault.json";
loadVault(vault, "your-password");
console.log(getSecret("API_KEY"));C. Native bridge (more secure)
import { decryptVaultNative } from "@secure-env-vault/react-native-sdk";
import vault from "./.env.vault.json";
(async () => {
const secrets = await decryptVaultNative(
JSON.stringify(vault),
"your-password"
);
console.log(secrets);
})();Security Notes
- Native decryption is more secure: Secrets are never exposed in the JS bundle.
- Never commit your password: Use secure storage or runtime injection for the decryption password.
- Vault file should be bundled with your app, not the raw .env.
Expo Support
Expo (managed workflow) does not support custom native modules, so you must use the JS-only fallback:
import { loadVault, getSecret } from "@secure-env-vault/react-native-sdk";
import vault from "./.env.vault.json";
const password = "your-password";
loadVault(vault, password);
console.log(getSecret("API_KEY"));Limitations:
- Secrets are decrypted in JS, so they are more easily accessible in the bundle.
- For maximum security, use Expo Bare workflow or a custom dev client with native modules.
For more details, see the Expo docs or open an issue for help.
