getstream env
Fetch an app's API key (and secret, for server targets) and write them into the file your platform expects. Run it from a directory linked with getstream init, or point it at an app another way - see how credentials are resolved.
getstream env
getstream env --target next
getstream env --app-id 1608483The publishable key is written with the framework's client prefix. The server-only secret is written for server targets and omitted for client-only ones. The secret is only ever written to the file, never printed.
Targets
| Target | File | Key variable | Secret |
|---|---|---|---|
web |
.env |
STREAM_API_KEY |
yes |
next |
.env.local |
NEXT_PUBLIC_STREAM_API_KEY |
yes |
vite |
.env.local |
VITE_STREAM_API_KEY |
no |
expo |
.env |
EXPO_PUBLIC_STREAM_API_KEY |
no |
ios |
Secrets.xcconfig |
STREAM_API_KEY |
no |
android |
local.properties |
STREAM_API_KEY |
no |
flutter |
dart_defines.json |
STREAM_API_KEY |
no |
The target is autodetected from the project. In an interactive terminal the CLI shows a platform picker preselected to the detection, so a wrong guess is one keystroke to fix; in a non-interactive run a failed detection errors and asks for --target.
Flags
| Flag | Effect |
|---|---|
-t, --target <name> |
Target platform. One of the values above. Default: autodetect. |
-o, --out <file> |
Write to this file instead of the target's default. |
--no-gitignore |
Skip the .gitignore safety check. |
--app-id <id> |
Write this app's credentials instead of the linked project's. |
Behavior
- Updates the key and secret lines in place if they exist, appends them if not, and leaves every other line untouched. Re-run it after rotating keys.
- Creates the file if it doesn't exist.
- Writes a
# Stream app: <name> (<id>)comment above the key variable, so the file says which app it belongs to. - Adds the file to
.gitignoreunless--no-gitignoreis passed, and warns when the written file is already tracked by git - a tracked secret file needs agit rm --cachedbefore the ignore takes effect. - For the mobile targets, prints the wiring steps the file needs: Flutter runs with
--dart-define-from-file=dart_defines.jsonand reads the key withString.fromEnvironment; iOS setsSecrets.xcconfigas the target's configuration file and exposes the key throughInfo.plist; Android readslocal.propertiesin the modulebuild.gradleand exposes the key as abuildConfigField.
See also
- Use the CLI in CI: credentials for headless workflows
- Backend SDKs: the server SDKs these keys are written for