To begin, let’s create an app, populate its base environment, and then add an additional environment. You’ll first need to create or log in to a Mothership account.
Replace the contents of the editor with the following snippet:
{
"name": "Mothership sample config",
"urls": {
"main": "https://mothership.cloud",
"dashboard": "https://app.mothership.cloud",
"docs": "https://docs.mothership.cloud"
}
}
Click the “Save” button in the lower-right corner.
Now that we have our app and base config, we still need to create our first real environment. In this scenario, our base config has what we might think of as “production” values in it. If they aren’t overridden by another environment, that’s what the client will receive.
Let’s now create a config for a staging environment.
base
environment.)staging
) and click “Create.”env
field set to the name of the environment. This can be useful for debugging
purposes or for use with template pointers.Update the config so that the result looks something like this:
{
"env": "staging",
"urls": {
"dashboard": "https://app.staging.mothership.cloud"
}
}
Click the “Save” button in the lower-right corner.
Now we’re ready to connect a client and view the result.
Mothership supports a growing number of languages and frameworks. To view a complete list of official clients and those developed by the community, see the Client SDK docs.
The examples GitHub repository contains sample implementations for each supported platform. Check it out to see how a client might be used in real world scenarios.
Template pointers are a powerful mechanism for making configurations more dynamic. Let’s add a template pointer to our sample config.
Change the base config to look like this:
{
"name": "Mothership sample config ${env}",
"urls": {
"main": "https://${url_prefix}mothership.cloud",
"dashboard": "https://app.${url_prefix}mothership.cloud",
"docs": "https://docs.${url_prefix}mothership.cloud"
},
"url_prefix": ""
}
Save that config, return to the app’s list of environments, and now open the “staging” environment.
Change the staging config to look like this:
{
"env": "staging",
"url_prefix": "${env}."
}
Save the config.
Now, when the staging environment config is requested, it will populate the correct URLs for that environment without needing to manually specify them. Now, if some part of the domain ever changes, we can simply update the base environment instead of needing to change other environments. As a bonus, this will still work perfectly for production.