On this page
Realm Values and Realm Secrets are static, server-side constants that you can access or link to from other components of your application. You can access Values directly from Realm Functions and rule expressions and link Secrets to configuration values for authentication providers.
A value is a named reference to a piece of static data stored by MongoDB Realm that you can access in functions and rule expression. Values provide an alternative to hardcoding configuration constants directly into your functions and rules. In other words, values allow you to separate deployment-specific configuration data from the business logic of your app.
Realm Values can resolve to two types of data:
- A plain text Value resolves to a regular JSON object, array, or string that you define.
- A secret Value resolves to the value of a Secret.
A Secret is a private value that is stored on the MongoDB Realm backend, hidden from users, and not included in exported applications. Secrets are useful for storing sensitive information such as an API key or an internal identifier.
You cannot directly read the value of a Secret after defining it. Instead, you link to the Secret by name in authentication provider and service configurations. If you need to access the Secret from a Function or Rule, you can link the Secret to a Value.
A Secret value has a maximum character length of 500 characters.
An environment value is similar to a regular text Value but can dynamically resolve to one of multiple values depending on an application-wide environment tag. You can specify different values for each of the following supported environment tags:
For more information on how to create environment values, see
Define Environment Values. You can access defined environment values
in functions with
context.environment.values() and in rule
Learn how to store JSON data in a static, server-side Realm Value.
Learn how to securely store sensitive data such as API keys and client Realm secrets.
Learn how to use dynamic values that can change depending on your app's environment.
Learn how to reference the data stored in a Realm Value from a Function or Rule expression.
- Realm Values and Realm Secrets are server-side constants you can use in your Realm app.
- Realm Values allow you to separate deployment-specific configuration data from the business logic of your app.
- Realm Secrets store sensitive data. You cannot export or directly read a Secret. Instead, you access a Secret indirectly via a named Realm Value.