The Secrets Manager allows you to store and encrypt API keys and other secrets on your site. With the Secrets API, you can safely work with secrets in your backend code.

Follow this general procedure for working with API keys or other secrets using the Secrets Manager:

  1. Get private information such as an API key from a 3rd-party service.
  2. Store the private information as a new secret in the Secrets Manager in your site's dashboard or with the createSecret() function. Assign a name to the secret.
  3. In your backend code, instead of hardcoding the API key, use the getSecret() function with the secret name assigned in the Secrets Manager. When the code runs, the value of the secret is extracted from the Secrets Manager.

Note: To create and manage secrets with the Secrets API, you must add a Members Area to your site. The Members Area is not required to retrieve secrets with getSecret().

To use the Secrets API, import wixSecretsBackend from the wix-secrets-backend module:

import wixSecretsBackend from 'wix-secrets-backend';
javascript | Copy Code

Was this helpful?