javascript1 Min Read

Tutorial - How to Setup Strapi Backend with Mongodb

Gorav Singal

May 01, 2021

TL;DR

Set up Strapi headless CMS with MongoDB using Docker, configure content types, and get ready-made REST APIs with built-in authentication.

Tutorial - How to Setup Strapi Backend with Mongodb

Introduction

In this step-by-step tutorial, we will setup strapi headless CMS

Some of the advantages of using Strapi:

  • You can define a content type and many custom fields.
  • You get ready-made REST APIs for all those content types
  • Every data is available through REST APIs
  • All basic CRUD operations are available to you by just defining a content type.
  • And the most important step is the security. It provides authentication layer build-in. You don’t have to worry about writing code for authentication.

Lets start.

Pre-requisites

You need to have following installed:

  • node.js
  • docker

First run MongoDB

I will use docker for running MongoDB, and use following docker-compose.yml file

version: '3.3'
services:
  mongodb:
    image: mongo:4
    ports:
      - "27017:27017"
    volumes:
      - ./mongo:/data/db

And, run mongodb by following command:

docker-compose up -d

Install Strapi with Mongodb

Lets create a Strapi project, and call it api

npx create-strapi-app api

Following are the screenshots for next steps, (choosing mongodb installation and others).

Choose your installation type: Custom

Strapi Installation

Choose Mongodb

Strapi Mongodb

Mongodb Configuration

Strapi Mongodb Configuration

Run Strapi Project in Development mode

npm run develop

It will run the server on http://localhost:1337/ Open it in your browser.

Strapi Server

Register yourself as admin.

Once you open the url: http://localhost:1337/, you will see admin panel. Now you can configure your backend, and can create new content types.

Share

Related Posts

Strapi Tutorial - How to Configure Slug to have Nice URLs for SEO

Strapi Tutorial - How to Configure Slug to have Nice URLs for SEO

Introduction In our previous posts, we have seen How to Create Article in Strapi…

How to Create Article by REST API and Configure only Author can Edit/Update/Delete articles

How to Create Article by REST API and Configure only Author can Edit/Update/Delete articles

Introduction In this post, we will see: create a test user Authenticate it via…

Tutorial - How to Create a Content-type, and Configure User Permissions for REST APIs

Tutorial - How to Create a Content-type, and Configure User Permissions for REST APIs

Introduction In this post, we will see how we can create a content type. And…

How to Deploy Strapi with Next.js Frontend with Nginx Proxy and URL Redirect with Docker

How to Deploy Strapi with Next.js Frontend with Nginx Proxy and URL Redirect with Docker

Agenda I will cover following in this post: Prepare Docker image for Next.js app…

How to use Draft.js WYSWYG with Next.js and Strapi Backend, Edit/Update Saved Article

How to use Draft.js WYSWYG with Next.js and Strapi Backend, Edit/Update Saved Article

Introduction This post is in contuation of our previous post: How to use Draft…

How to use Draft.js WYSWYG with Next.js and Strapi Backend, Create and View Article with Image Upload

How to use Draft.js WYSWYG with Next.js and Strapi Backend, Create and View Article with Image Upload

Introduction In this post, we will use in Next.js with strapi. And, we will…

Latest Posts

AI Video Generation in 2025 — Models, Costs, and How to Build a Cost-Effective Pipeline

AI Video Generation in 2025 — Models, Costs, and How to Build a Cost-Effective Pipeline

AI video generation went from “cool demo” to “usable in production” in 2024-202…

AI Models in 2025 — Cost, Capabilities, and Which One to Use

AI Models in 2025 — Cost, Capabilities, and Which One to Use

Choosing the right AI model is one of the most impactful decisions you’ll make…

AI Image Generation in 2025 — Models, Costs, and How to Optimize Spend

AI Image Generation in 2025 — Models, Costs, and How to Optimize Spend

Generating one image with AI costs between $0.002 and $0.12. That might sound…

AI Coding Assistants in 2025 — Every Tool Compared, and Which One to Actually Use

AI Coding Assistants in 2025 — Every Tool Compared, and Which One to Actually Use

Two years ago, AI coding meant one thing: GitHub Copilot autocompleting your…

AI Agents Demystified — It's Just Automation With a Better Brain

AI Agents Demystified — It's Just Automation With a Better Brain

Let’s cut through the noise. If you read Twitter or LinkedIn, you’d think “AI…

Supply Chain Security — Protecting Your Software Pipeline

Supply Chain Security — Protecting Your Software Pipeline

In 2024, a single malicious contributor nearly compromised every Linux system on…