Skip to content

What you should know before getting Started with Strapi

An Introduction to Strapi

Strapi is the headless content management system (CMS) that empowers you to store, manage, and edit your website’s content while generating a sleek API for easy access. While Strapi may seem like a breeze to get started with, there are a few crucial points to grasp before diving in headfirst.

Setting up my first Strapi app took me a couple of evenings, but the lessons I learned along the way were invaluable. Allow me to share my newfound wisdom so you can embark on your Strapi journey with confidence.

1. Strapi requires two main resources:

Required Resource 1: A Database (such as PostgreSQL, MySQL, or SQLite)

Choose your preferred provider and ensure you have the necessary credentials set as environment variables that will be used in the config/database.js file.

Required Resource 2: A Blob Storage Provider

You have a range of options when it comes to blob storage providers for Strapi: Azure Storage, AWS S3, Cloudinary, and Google Cloud. Take a moment to choose the provider that suits your needs best.

Once you’ve selected your preferred provider, it’s time to find the perfect plugin to integrate it with Strapi. Keep in mind that there’s a variety of plugins available, created both by the Strapi community and the Strapi team themselves. Explore these options and pick the one that aligns with your requirements.

To make the magic happen, you’ll need to attach the chosen plugin as the uploads object within the config/plugins.js file. This configuration step ensures seamless integration between Strapi and your selected blob storage provider.

Here’s an example configuration snippet specifically tailored for Azure Storage:

module.exports = ({ env }) => ({
  upload: {
    config: {
      provider: "strapi-provider-upload-azure-storage",
      providerOptions: {
        account: env("STORAGE_ACCOUNT"),
        accountKey: env("STORAGE_ACCOUNT_KEY"), //either account key or sas token is enough to make authentication
        //sasToken: env("STORAGE_ACCOUNT_SAS_TOKEN"),
        //serviceBaseURL: env("STORAGE_URL"), // optional
        containerName: env("STORAGE_CONTAINER_NAME"),
        defaultPath: "assets",
        //cdnBaseURL: env("STORAGE_CDN_URL"), // optional
      },
    },
  },
});
Code language: JavaScript (javascript)

With this code snippet in place, you’re all set to leverage the wonders of Azure Storage in conjunction with your Strapi-powered project.

Remember, it’s all about setting up your database and storage before getting your hands dirty with actual work.

2. The Strapi Workflow

Here is the gist of the Strapi workflow: Create content-types with the Content-Type Builder and then add content with the Content Manager.

You’ll manage your content-types using the Content-Type Builder, which is enabled when you start Strapi via the command strapi develop during the development phase. Content-Type Builder is your command center for creating content-types and organizing relations between them. The Content-Manager is straightforward; you will find its interfaces like other CMS you have used.

When you’re ready to go live, you’ll want to build your Strapi project using strapi build. This step compiles your code, saves your content model schemas, and prepares it for production deployment. Deploy the build to your hosting environment following the docs deployment guide.

The Content-Type Builder can only be used in dev mode, as it actively generates your API in code.

3. Migrations – Beware!

When starting your Strapi journey, it’s crucial to understand early on how Strapi manages the database it’s connected to. Strapi uses the migrations pattern, which means that as you develop Content-Types, it creates scripts to update the database to keep in line with the changes. At Strapi start-up, these migration scripts are run forcefully! They will force the database in the form to match your latest changes. This means that any tables and columns in the database that are no longer used or were not accounted for by the migration scripts will be potentially removed – there are warnings in the docs about this in several places, but it is easy to miss.

What does this mean? You need to use environments (e.g., one database for dev and one for prod), and you probably want to back your production database before you deploy any drastic schema changes. Even better, have a staging environment to confirm migration success and catch any missing data before deploying to production. It goes without saying, don’t point two instances of Strapi at the same database.

Check out Strapi’s data management features that allow content import and export to keep the data in your environments backed up and in sync. Overall, it helps to have an understanding of database relations and constraints so you can recognize when data might be lost due to migration or how to make Content-Type changes that won’t affect relational columns.

Don’t Give Up

Next, let’s address an aspect that may not be as smooth sailing as it seems. While this blog may paint a picture of an effortless setup, I encountered some challenges when it came to adjusting ports for Strapi while working locally. But fear not! When faced with such hurdles, remember that the GitHub issues for Strapi are your trusted companions.

The vibrant Strapi community thrives on GitHub, and it’s the perfect place to seek solutions and insights. Dive into the vast repository of issues, discussions, and resolutions. You’ll find a wealth of knowledge shared by fellow developers who have encountered similar obstacles along their Strapi journey.

TL;DR

To sum it up, Strapi is a game-changer regarding headless CMS. It’s the go-to platform for effortlessly storing, managing, and accessing content for your website. And guess what? Getting started is a breeze when you know the deal-breakers.

Here’s the scoop: Strapi craves two essential resources—a database and a blob storage provider. Don’t fall for the quick start trap; set up your own database and storage for a rock-solid foundation. Oh, and remember the workflow: Content-Type Builder in development mode, build, deploy, and use the Content Manager to add content. Armed with this knowledge, you’ll be riding the Strapi wave like a pro, unleashing the true potential of its sleek API for crafting exceptional websites.

A Shameless Plug

Unlock the true potential of your business web apps with IntelliTect, the experts in integrating your CMS with stunning frontends that will make your digital presence shine like never before. Or check out Coalesce, our code-first CMS designed for business applications.

Does Your Organization Need a Custom Solution?

Let’s chat about how we can help you achieve excellence on your next project!