Toggling between Staging vs Production Data

📘

On-prem customers may consider a different strategy

If you are running Retool on-prem, you may consider running multiple Retool instances instead of using the strategy described below.

Toggling between Staging vs Production Data

Staging data allows you to display and test against a nonsensitive copy of your production data.

In Retool, you can set up a resource connection to your database and add both staging and production credentials within the same resource. Then, as long as all resources used in your app have both staging and production credentials set up, you can easily switch between and develop with the two.

In this doc, we’re going to go over setup and in-app usage.

Setup

In order to set up staging, you must first set up and save your production environment.

Once you save your resource with production credentials, an “Enable staging” toggle will appear. Once you toggle it ON, you can click on the “Staging” tab, enter your staging credentials and save.

You'll only see this option after you've saved your production credentials.You'll only see this option after you've saved your production credentials.

You'll only see this option after you've saved your production credentials.

Usage

A Production vs Staging switch will be available for apps where all resources have both production and staging credentials set up in Retool.

Once you switch to staging, the page will refresh and no further action is needed on your end—your queries will all now use their staging credentials.

App's resource credentials

Switch?

All have production and staging

Switch

Some have production and staging, some have production only

Greyed out switch with a pop-up indicating the production-only resources

All have production only

No switch

Example of the switch ↓

Note the orange button and line to indicate the staging environment.Note the orange button and line to indicate the staging environment.

Note the orange button and line to indicate the staging environment.

Example of the greyed out switch ↓

`query1` is using the `ecommerce` resource which doesn't have staging configured.`query1` is using the `ecommerce` resource which doesn't have staging configured.

query1 is using the ecommerce resource which doesn't have staging configured.

Example of no switch ↓

No switch in the top menu if all resources are production-only.No switch in the top menu if all resources are production-only.

No switch in the top menu if all resources are production-only.

Caching and Public Apps

The switch simply adds a flag to your cache that tells your browser which environment to use.

If you switch to “Staging” in one app, then open a second app that also has staging available, the second app will automatically open in staging.

📘

The default environment for Public Apps is production. You can add a URL Query Param to view the app in staging.

Environment Query Parameter

Aside from the switch, another way to change environments is through the _environment URL query parameter added at the very end of your app URL.

https://yourcompany.retool.com/apps/my-app?_environment=production opens in production.

https://yourcompany.retool.com/apps/my-app?_environment=staging opens in staging.

📘

Read more about other Retool supported URL Query Parameters here.

Retool Context

If you ever need your code to know which environment you’re in, you can access the Global retoolContext object’s environment property, like {{ retoolContext.environment }}. This will return either “staging” or “production”, depending on the current environment.


Did this page help you?