Here's a guide on how to use Nhost with multiple environments and how to set up a workflow around them.
For this example, we'll set up one production environment and one staging environment.
Create a new Git repo and use the CLI and the
nhost init command to initialize a new project.
Also, create a new branch called
You should now have a Git repo with a
main branch and a
To have two environments, we need to create two projects on Nhost Cloud.
Set your production project to use the
main branch as the Deployment Branch and your staging project to use the
staging branch as the Deployment Branch. This way, the production project will only deploy new changes to the
main branch and the staging project will only deploy new changes to the
Now, use the CLI to do local development. And use a specific feature branch while doing development.
Once you're ready to test your changes to staging, create a pull request from your feature branch to the
staging branch. Then, merge the pull request to
This will automatically trigger a new deployment to the staging project on the Nhost platform.
Once you've tested your changes in the staging environment, you can create a new pull request from the
staging branch to the
main branch. Then, merge the pull request to
This will automatically trigger a new deployment to the production project on the Nhost platform.
Now you have two environments, one for staging and one for production. You can use this workflow to do local development, and test your changes in a staging environment before deploying them to production.