Skip to main content

Front-End Development

Strapi:Unleash the Power to Build Modern,Highly Customizable Websites with the Ultimate Headless CMS

Istock 917895628

Strapi is the leading open-source headless CMS. It’s 100% JavaScript/TypeScript, fully customizable, and developer-first. Its flexibility and scalability make it an ideal choice for businesses and organizations seeking to create unique digital experiences.

  • Self-hosted or Cloud: We can host and scale Strapi (open-source headless CMS) projects the way you want. We can save time by deploying Strapi Cloud or deploying to the hosting platform of your choice, such as AWS, Azure, Google Cloud, or DigitalOcean.
  • Modern Admin Panel: An elegant, completely customized, and fully expandable admin panel.
  • Multi-database support: We can choose the database: PostgreSQL, MySQL, MariaDB, and SQLite.
  • Customizable: We can easily construct logic by completely changing APIs, routes, or plugins to meet our exact requirements.
  •  Fast and Robust: Strapi’s Node.js and TypeScript-based architecture ensures fast and robust performance.
  •  Front-end Framework: Use any front-end framework (e.g., React, Next.js, Vue, Angular), mobile applications, or even IoT.
  •  Security: Default security features include reusable rules, CORS, CSP, P3P, Xframe, and XSS.
  •  Strapi CLI: Use the powerful CLI to scaffold applications and APIs on the fly.
  • Headless Architecture: Strapi’s headless architecture allows developers to build custom front-end applications using their preferred frameworks and libraries, while Strapi handles content management.
  • Customizable Content Models: Create custom content models to suit your specific needs, including text, images, videos, and more.
  • API-First Approach: Strapi’s API-first strategy enables seamless integration with various front-end frameworks and libraries.

Strapi Headless CMS Installation

Strapi projects can be installed either locally on a computer or on a remote server.

Installation Using CLI

Create a project on your local machine using the command-line interface (CLI). Before installing Strapi, the following requirements must be installed on your computer:

  • Node.js: Only Active LTS or Maintenance LTS versions are supported (currently v18, v20, and v22). Odd-number releases of Node, known as “current” versions of Node.js, are not supported (e.g., v19, v21).
  • Your preferred Node.js package manager:
  • Python (if using an SQLite database)
  • A supported database is also required for any Strapi project:
Database Recommended Minimum
MySQL 8.0 8.0
MariaDB 10.6 10.5
PostgreSQL 14.0 12.0
SQLite 3 3

Installation Using Docker

Create a custom Docker container from a local project.

Getting Started with Strapi

To start using Strapi, perform these steps:

yarn create strapi # using yarn

npx create-strapi@latest # using npx

pnpm create strapi # using Pnpm (caution: Strapi Cloud does not support pnpm yet)

Strapi Installation
The terminal will ask you whether you want to log in or sign up to Strapi Cloud (and start using your free 14-day trial projects) or skip this step. Use the arrow keys and press Enter to make your choice. If you choose to ignore this step, you will need to host the project yourself. The terminal will prompt you to answer a few questions. For each of them, if you press Enter instead of typing something, the default answer (Yes) will be used:

Strapi Installation Options

Running Strapi on the CMD / VSCode terminal

npm run develop # using npm
yarn develop # using Yarn

Strapi Installation Welcome

Content Modeling

Strapi’s content modeling system allows you to create custom content types, including text, images, videos, and more. You can also create relationships between content types, enabling complex data structures.

  • Content Types: Create custom content types, including articles, products, and users.
  • Fields: Add fields to your content types, including text, number, date, and more.
  • Relationships: Establish relationships between content types to enable complex data structures.

Creating Content Models

  1. Create a New Content Model: Create a new content model by clicking the “Create a new content model” button in the admin panel.
  2. Add Fields: Add fields to your content model, including text, numbers, dates, and more.
  3. Establish Relationships: Establish relationships between content models, enabling complex data structures.
Strapi Content Type Administration Panel

Strapi headless CMS – From the admin panel, you will be able to manage content types and write their actual content, but also manage users, both administrators and end users of your Strapi application.

 

Strapi headless CMS - Content Type About

Content-Type Builder – From the Content-Type Builder, accessible via the main navigation of the admin panel, users can create and edit their content types.

 

Strapi headless CMS - Content Type Create Field About

Configuring content-types fields – Content-types are composed of one or several fields. Each field is designed to contain a specific kind of data, filled in the Content Manager.

 

Strapi headless CMS - Content Type Create A Single Type

Creating content types: The Content Type Builder allows you to create new content types, including single and collection types, as well as components.

 

Strapi headless CMS - Content Type About Blog

Strapi headless CMS – Added Content on About Us that will reflect on API

API and Integration

Strapi’s API-first approach enables seamless integration with various front-end frameworks and libraries.

  • RESTful API: Strapi provides a RESTful API for interacting with your content.
  • GraphQL API: Strapi also supports GraphQL, enabling more flexible and efficient data querying.
  • Webhooks: Use webhooks to notify external services of changes to your content.

API Endpoints

  1. Create API Endpoints: Add API endpoints to your content models to enable CRUD (Create, Read, Update, and Delete) activities.
  2. Use API Endpoints: Use the API endpoints to interact with your content, either through the Strapi API or through your front-end application.

Authentication and Authorization

Strapi provides built-in support for authentication and authorization, enabling you to control access to your content.

  • User Management: User management includes the creation and administration of users, roles, and permissions.
  • Authentication: Use JWT or session-based authentication to secure your API.
  • Authorization: Use roles and permissions to manage who can access your material.

Benefits and Advantages of Strapi Headless CMS

  • Flexibility: Strapi offers scalability and flexibility because of its headless architecture and configurable content modeling.
  • Scalability: Since Strapi is built on Node.js, it can scale and perform efficiently.
  • Ease of Use: Strapi’s intuitive interface and API make it easy to use and integrate with your front-end application.

Front-end Integration

  • Choose a Front-end Framework: To create your application, choose a front-end framework such as React, Angular, or Vue.js.

Strapi Supports all Front-end Integration

  1. React CMS
  2. Next.js CMS
  3. Tanstack CMS
  4. Vue.js CMS
  5. Nuxt.js CMS
  6. Astro CMS
  7. Flutter CMS
  8. Svelte CMS
  9. React Native CMS
  • Utilize the Strapi API: Leverage the Strapi headless CMS API to interact with your content and deliver a seamless user experience.

Example Use Cases

  • Headless Blog: Utilize Strapi as a headless CMS for your blog, enabling the creation of custom content models and API endpoints.
  • Ecommerce Platform: Use Strapi to manage product data, orders, and customers for your e-commerce platform.
  • Portfolio Website: Utilize Strapi to create a portfolio website that showcases your work and projects.

If you need a comparison of different technologies with Strapi’s headless CMS, please visit this link: Headless CMS Comparison.

Example Use Case: Building a Simple Ecommerce Platform on Strapi

Let’s create a simple ecommerce platform using Strapi.

Content Models

  • Product
  • Name (text)
  • Description (text)
  • Price (number)
  • Image (media)
  • Order
    • Customer Name (text)
    • Order Date (date)
    • Total (number)
    • Products (relation to Product)

API Endpoints

  • GET /products: Retrieve a list of all products
  • GET /products/:id: Retrieve a single product by ID
  • POST /products: Create a new product
  • PUT /products/:id: Update an existing product
  • DELETE /products/:id: Delete a product
  • GET /orders: Retrieve a list of all orders
  • GET /orders/:id: Retrieve a single order by ID
  • POST /orders: Create a new order
  • PUT /orders/:id: Update an existing order
  • DELETE /orders/:id: Delete an order

Example Response

JSON – for accessing the local environment URL:

localhost:1337/api/products

Code Examples

Product JSON Response

When you fetch a product from the API (GET /products/:id), you might get a response like this:

{
  "data": {
    "id": 1,
    "attributes": {
      "name": "Wireless Headphones",
      "description": "High-quality wireless headphones with noise cancellation.",
      "price": 129.99,
      "image": {
        "url": "/uploads/headphones_image.jpg",
        "alternativeText": "Wireless Headphones"
      },
      "category": {
        "data": {
          "id": 2,
          "attributes": {
            "name": "Electronics",
            "description": "Electronic gadgets and accessories."
          }
        }
      }
    }
  }
}

Category JSON Response

When you fetch a category (GET /categories/:id), the response might look like this:

{
  "data": {
    "id": 2,
    "attributes": {
      "name": "Electronics",
      "description": "Electronic gadgets and accessories."
    }
  }
}

Order JSON Response (Example after user places an order)

When a user places an order (POST /orders), your response could look like this:

{
  "data": {
    "id": 1,
    "attributes": {
      "customer_name": "John Doe",
      "items": [
        {
          "id": 1,
          "quantity": 2,
          "product": {
            "data": {
              "id": 1,
              "attributes": {
                "name": "Wireless Headphones",
                "price": 129.99
              }
            }
          }
        }
      ],
      "total_amount": 259.98,
      "status": "pending"
    }
  }
}

Additional Resources

  • Strapi Documentation: The official Strapi headless CMS documentation provides a comprehensive guide to getting started with Strapi.
  • Strapi Community: The Strapi community is an excellent resource for getting help and support with your Strapi project.
  • Strapi Tutorials: The Strapi tutorials provide step-by-step guides to building specific applications and integrations with Strapi.

 

Conclusion

Strapi is a powerful and flexible headless CMS that enables developers to build modern, customizable websites and applications. Its first approach to API, custom content modeling, and authentication and authorization features makes it an ideal choice for a wide range of use cases.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Akash Badole

Akash S Badole is a technical consultant at Perficient with over six years of experience in UI. His expertise includes Reactjs, NextJs, WordPress, HTML, CSS, TailwindCSS, and Sitecore. Akash has worked on several UI projects and specializes in front-end development.

More from this Author

Follow Us