top of page
Get a Demo
Get a Free Quote

Deploy Strapi on Heroku - a Detailed Guide

Nov 17, 2023

2 min read

0

5

0

https://www.sublimetext.com/Strapi is a headless CMS that allows developers to build APIs quickly and easily. Heroku is a cloud-based platform that enables developers to build, run, and operate applications entirely in the cloud. In this article, we will walk you through how to deploy Strapi on Heroku in a step-by-step manner. We will cover everything from installing Strapi locally to pushing your Strapi codebase to Github, connecting your Heroku account to your Github (the project repository), enabling Automatic Deploy, and connecting your Strapi project to Postgres add-on database provided by Heroku. You can find the detailed guide here.


Prerequisites

  • A Github account

  • A Heroku account

  • Git installed on your machine

  • Node.js v16+ installed

  • Code Editor ( sublime editor)

Steps

  1. Install Strapi locally by running the following command on your machine:

npx create-strapi-app my-project --quickstart

This will create a folder called my-project and automatically install Strapi. After that, you should be able to access http://localhost:1337/admin. Opening this for the first time will redirect you to http://localhost:1337/admin/auth/register-admin. This is because we have no super admin yet in the database. By default, Strapi uses SQLite as a file-based database. You need to create your first super admin locally. I want you to know that Heroku does not completely support SQLite. Read more about SQLite support. So it is important to understand that the super admin you will be creating locally will differ from the one that you will create when you host on Heroku. And of course, you need to have a super admin locally because that is how you will be able to create a new collection type schema as Strapi does not allow that to be done in production.

  1. Create a repository on Github and run the following command in the root of your Strapi instance:

git init
git add .
git commit -m "first commit"
git branch -M main
git remote add origin <https://github.com/USERNAME/NAMEOFREPOSITORY.git>
git push -u origin main

Where USERNAME is your GitHub username and NAMEOFREPOSITORY is the name given to your just created repository.

  1. Connect your Heroku account to your Github (the project repository) and enable Automatic Deploy.

  2. Connect your Strapi project to Postgres add-on database provided by Heroku. You can do this by following the instructions provided in this article.

That's it! Your Strapi instance should now be deployed on Heroku. If you have any issues, feel free to refer to the official Strapi documentation or Heroku documentation.


Source: Conversation with Bing, 17/11/2023 (1) Deploy a Strapi API on Heroku in 5 min. https://strapi.io/blog/deploying-a-strapi-api-on-heroku. (2) Deploying a Strapi project on Heroku - DEV Community. https://dev.to/hayleycodes/deploying-a-strapi-project-on-heroku-1aba. (3) How to deploy Strapi backend to Heroku with Postgres addon?.


https://stackoverflow.com/questions/63441231/how-to-deploy-strapi-backend-to-heroku-with-postgres-addon. (4) Deploy a Strapi project on Heroku using Postgres add-on.


https://strapi.io/video-library/deploy-heroku-postgres-add-on. (5) undefined. https://github.com/USERNAME/NAMEOFREPOSITORY.git. (6) undefined.


https://hayley.codes/blog/using-strapi-to-create-a-blog. (7) Blog SEO: The Complete Guide - Ahrefs. https://ahrefs.com/blog/blog-seo/. (8) Blog SEO: How to Search Engine Optimize Your Blog Content. https://blog.hubspot.com/marketing/blog-search-engine-optimization. (9) How to Do SEO - 11+ Practical SEO Examples For 2021 - Apollo Digital.


https://apollodigital.io/blog/seo-examples. (10) A guide to using Markdown to write blog posts – Leon Paternoster. https://www.leonpaternoster.com/posts/writing-markdown-blogging-guide/. (11) The Complete Guide to Blogging in Markdown - Testsuite.


https://testsuite.io/blogging-in-markdown. (12) Creating & editing blog posts with Markdown and GitHub - Sourcegraph. https://handbook.sourcegraph.com/departments/marketing/blog/.

Comments

Share Your ThoughtsBe the first to write a comment.
bottom of page