How to create environment variables for Realm Functions?

Where is the best place to store things like API keys, etc when creating functions?

More context:

I’m writing a function to handle email confirmation of a user authenticated with email/password, and I’d like to use Mailgun for this. The mailgun.js package doesn’t appear to be supported by Realm, so I figured I could just use a standard ajax library like axios to make the Mailgun API calls. However, I’d still want a way of securely storing the API keys I need to make the calls. Any suggestions?

1 Like

Hi @Annie_Sexton,
You can store things like API keys in a Realm Secret… https://docs.mongodb.com/realm/values-and-secrets/#:~:text=A%20Secret%20is%20a%20private,a%20Secret%20after%20defining%20it.

Note that you also need to wrap that Realm Secret with a Realm Value so that your function can access it.

3 Likes

Thanks @Andrew_Morgan ! Sounds like I was just searching for the wrong term, appreciate the help

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