Creating Strapi App with PostgreSQL

Ceren Keles
Jan 21 · 5 min read

Today I’m going to tell a bit about Strapi and try to show how can we start and configure a Strapi application using the PostgreSQL database.

You will find the below contents with the article;

  1. What is Strapi
  2. Installing Postgres
  3. Create Strapi App
  4. What the application looks like

Let’s do this 🚀

  1. What is Strapi?

Strapi is a flexible, open-source Headless CMS that gives developers the freedom to choose their favorite tools and frameworks while also allowing editors to easily manage and distribute their content. By making the admin panel and API extensible through a plugin system, Strapi enables the world’s largest companies to accelerate content delivery while building beautiful digital experiences.

To see the demo from the Strapi youtube channel;

To see the documentation and learn more about the Strapi I suggest the link below;

2. Installing PostgreSQL

I use homebrew here, so you can install homebrew using the command;

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

We can go through with the postgres image we download by Homebrew or let Docker create an image for us automatically. To install PostgreSQL via Homebrew;

brew install postgres

I choose the way with Docker complete everything for us. Let’s create a docker container for Postgre, so if you don’t have Docker, you can download it easily;

Now we are ready to create a new docker container.

We fill the username for the database as “postgres” and the password as “123” and create the container;

docker run -d -p 5432:5432 — name strapi-postgre -e POSTGRES_PASSWORD=123 postgres

The Docker Image is created automatically and now we can see the container is running in the list of containers;

docker ps -a

Let’s create a new database in Postgres. Run the image with the below command;

docker exec -it strapi-postgre bash

Now we’ll create the database inside of the container;

psql -U postgres

The database is created. Now we can quit the Postgres by using \q and exit commands. Let’s check the database we created using the password “123”;

psql -h localhost -p 5432 -U postgres -W

To see the list of databases we can use “\l” command. We see the “strapidb” is here. Let’s continue with creating the Strapi app.

3. Creating a Strapi App

First of all “node, npm and yarn” should be installed. The versions should be;

NodeJS >= 10.16 <=12NPM >= 6.xYarn >= 1.22.x

Now we’re ready to run the command to see the magic;

strapi-projects % yarn create strapi-app my-strapi-app

The command line is asking us to choose the installation type as Quickstart or Custom. We choose Custom (manual settings) now, but you can try to choose Quickstart to let all the choices will be selected by Strapi.

We choose Postgres for the database client. The rest of the requirements should be like;

The host and port information (127.0.0.1:5432) is the default for Postgres.

Now the application is fully created and as you can see that we can start the application using the command;

yarn develop

Now the application is running and if we open the URL http://localhost:1337/admin we can see the login screen and we choose a username and password for the admin pages and login easily.

4. What the application looks like

We can see the source codes;

That’s all! Hope you find the article helpful.

The sources that help me a lot (I’m grateful);

Thanks for reading! 🚀

Doğuş Technology

Doğuş Technology — Digital Solutions Group

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store