Deploying a Shopify app to Heroku can quickly turn into repetitive work — managing environment variables and running multiple commands to keep Shopify and Heroku in sync.
To simplify this process, I built shopify-heroku-cli a lightweight CLI that syncs your Shopify app’s environment variables with Heroku and deploys your app in just a couple of commands.
In this post, I’ll show you step-by-step how to deploy your Shopify app to Heroku using the tool.
1. Prerequisites
Before we start, make sure you have the following installed and configured:
- Node.js >= 16
- Shopify CLI — logged in to your Shopify app
- Heroku CLI — logged in to your Heroku account
- A Shopify app ready to deploy
- A Heroku app created (you can create one with
heroku create my-shopify-app)
2. Install the CLI
Install the CLI globally using npm:
npm install -g shopify-heroku-cli
This makes the shopify-heroku command available system-wide.
3. Sync Environment Variables
The first step is to set your Shopify app environment variables on your Heroku app.
You can do this with a single command:
shopify-heroku set-env your-heroku-app-name
This command automatically:
- Reads your Shopify environment variables
- Pushes them to your Heroku app
- Sets
SHOPIFY_API_KEY,SHOPIFY_API_SECRET, andSHOPIFY_APP_URLautomatically
If you have multiple Shopify config files (like shopify.app.live.toml), you can specify one:
shopify-heroku set-env your-heroku-app-name -c live
4. Create a heroku.yml File
Next, you’ll need a heroku.yml to tell Heroku how to build your app (using Docker):
echo -e "build:\n docker:\n web: Dockerfile" > heroku.yml
Commit the file to your repo:
git add .
git commit -m "feat: add heroku yml file"
5. Deploy to Heroku
Now you’re ready to deploy your Shopify app:
shopify-heroku deploy your-heroku-app-name
This command will:
- Ensure your Heroku app is configured for container deployment
- Set up the correct git remote (if missing)
- Automatically detect your main branch (
mainormaster) - Push your code to Heroku for deployment
Once complete, you can open your app directly:
heroku open --app your-heroku-app-name
6. Update the Shopify App URL
After deployment, you’ll need to update your app URL in your Shopify configuration file (shopify.app.toml) to point to your Heroku domain.
Example:
application_url = "https://your-heroku-app-name.herokuapp.com"
Then deploy your app to Shopify again to update the URL:
npm run deploy
7. (Optional) Automate Your Deploy Workflow
You can easily wrap this workflow into a script inside your package.json:
"scripts": {
"deploy:heroku": "shopify-heroku set-env your-heroku-app-name && shopify-heroku deploy your-heroku-app-name"
}
Now you can deploy to Heroku with a single command:
npm run deploy:heroku
Wrapping Up
Deploying a Shopify app to Heroku doesn’t have to be complicated.
With shopify-heroku-cli, you can handle environment syncing and deployment in just one command — no more manual setup or juggling multiple CLIs.
Check out the full documentation and source code here:
GitHub: imohamadnashaat/shopify-heroku-cli
npm: shopify-heroku-cli
If you find it useful, please share feedback to help make it even better.
Happy deploying!
Top comments (0)