Put different env files as secrets in expo

Does that even legit? I am thinking to put different .env files as to Secrets store to reuse them on build time for different app flavours (dev/staging/prod)

Does anybody accomplished that? I was thinking that since it is just a file I can put JSON inside and use it directly from app.config.ts.

But I am still was not able to run such idea successfully.

Hi @aminaev

I’m not quite sure what you’re trying to do. But Secrets are already made available to the build process as environment variables

1 Like

Thanks for getting back to me @wodin.

My idea was to use secret files to act as holders of all ENV variables.

say I have 40 different ENV variables necessary to be injected. As well I have 3 environments where those values are different.
Given limit of 100 - I cannot even fit my amount in to secret store.

But that is not my biggest concern. My concern is keys management as I’d need to prefix each key to be DEV_ or STAGING_ etc and then manage them.

So given that Expo offers secret storage of files - I was thinking of the way to wrap all of my env variables to file, store in under “ENV-{STAGE}” file name and then just reuse this name in app.config.ts.

And the way to implement that is not clear to me.

Does that makes sense from my explanation to you, @wodin ?

Nevermind, after v49 expo made things easier.
I came to a conclusion that best way for me with multiple environments is to utilize eas.json and inject all the variable via ‘env’ array.
Of course they MUST be public and follow EXPO_PUBLIC_ recommendation prefix.

Rest of the private secrets either injected from .env.* locally OR should be living in expo secrets section.

After I have all the variables injected - I can collect them in app.config.ts utilising EAS_BUILD_PROFILE or NODE_ENV and specifying different secrets for different environments.

Sorry for not getting back to you. I haven’t tried the new environment variable support.

Glad you got it sorted out!

Thanks for getting back @wodin !

I “thought” I sorted out.

But Expo does not makes my life easier when using build and update as update does not respect eas.json which again raises questions about how to support build/update correct way. And it looks I would come up with something different.

I am open to any ideas though.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.