Strapi v4 Documentation
website·Indexed 42 days ago
https://docs-v4.strapi.ioDeveloper and user documentation for Strapi v4, featuring guides on installation via CLI, the Content-type Builder, and the Marketplace. Includes technical API references for the Entity Service and Query Engine, plugin documentation for Email, Upload, and Users & Permissions, and comprehensive migration guides for upgrading from v3 to v4.
What's inside Strapi
- Controllers are JavaScript files containing methods (actions) that handle business logic and send responses to clients based on requested routes. They represent the 'C' in the Model-View-Controller (MVC) pattern. For complex logic, it is recommended to move code into services to maintain re-usable parts. Before customizing core controllers, consider if a custom route middleware is a better fit.
Overview of Strapi Providers
Providers allow you to extend the core capabilities of specific Strapi plugins. For example, you can use a provider to upload media files to AWS S3 instead of the local server, or use Amazon SES for emails instead of Sendmail. Currently, only the Upload and Email plugins are designed to work with providers. Providers can be official (via the Strapi Marketplace) or community-maintained (via npm).Overview of Strapi Custom Fields
Custom fields allow developers to add new field types to content-types and components in Strapi. Once registered, these fields appear in the Content-Type Builder and Content Manager.
Key architectural details:
- Custom fields must be registered on both the server and the admin panel to be fully functional.
- While they can be registered in global
registerfunctions insrc/index.jsandsrc/admin/app/js, the recommended approach is to develop a dedicated plugin. - In the model's schema, attributes using a custom field are represented with
type: 'customField'. - Custom fields can only be shared between different Strapi projects via plugins.
Overview of Strapi Admin Panel Settings
The Settings section in the Strapi admin panel is used by administrators to manage the application's behavior and configuration. It is divided into four primary sub-sections:
- Global Settings: Used for customizing the admin logo, managing API and Transfer tokens, configuring internationalization (i18n), media library assets, review workflows, and Single Sign-On (SSO).
- Administration panel: Used for managing administrator accounts, defining administrator roles, and viewing audit logs.
- Email plugin: Used to configure the system's email delivery settings.
- Users & Permissions plugin: Used to configure end-user roles, authentication providers, email templates, and advanced plugin settings.
Overview of Strapi Cloud
Strapi Cloud is a fully managed hosting platform built on top of the open-source Strapi headless CMS. It allows developers to deploy Strapi applications quickly by abstracting infrastructure management while maintaining the ability to customize the core Strapi capabilities.Overview of Strapi Policies
Policies are functions that execute specific logic on each request before it reaches the controller. They are primarily used to secure business logic. Each route can be associated with an array of policies. If a policy returnsfalse, the request is blocked; if it returnstrue(or nothing), the request proceeds to the next policy or the controller action.Overview of Strapi REST API query parameters
Strapi uses LHS bracket syntax (square brackets[]) for REST API query parameters to filter, sort, paginate, and select specific fields or relations. Starting from version 4.13, sending invalid query parameters results in an error status rather than being ignored. To avoid errors, ensure queried fields are in the correct format, are not private/password fields, and that the user has the necessary read permissions.Overview of the Strapi Email plugin
The Email plugin allows Strapi applications to send emails via a server or external provider. It is accessible globally via the
strapiAPI, making it usable in controllers, services, and lifecycle hooks.Prerequisites: A provider must be configured in
config/plugins.jsorconfig/plugins.ts.Note on Default Provider:
Sendmailis the default provider. While suitable for local development, it is not production-ready by default. For production, you must either configureSendmailfurther or switch to a production-ready provider.Overview of Strapi Cloud CLI
The Strapi Cloud CLI allows developers to manage authentication and deploy local projects to Strapi Cloud without requiring a remote Git repository. It is compatible withnpmandyarn. Because it is recommended to install Strapi locally, commands should be executed using a package manager prefix (e.g.,npm run strapi) or a node package executor likenpx.npx strapi help # OR npm run strapi help # OR yarn strapi helpOverview of Strapi Administrator Roles (RBAC)
Administrator roles are managed via the Role-Based Access Control (RBAC) feature located in the Administration panel section of the Settings sub-navigation. Strapi provides three default roles:
- Author: Can create and manage their own content.
- Editor: Can create content, and manage and publish any content.
- Super Admin: Has access to all features and settings (assigned by default to the first administrator created).
Overview of Strapi end-user roles
End-users are consumers of content displayed on front-end applications (websites, mobile apps, etc.) and do not have access to the Strapi admin panel. End-user roles and permissions are managed via the Users & Permissions plugin in the Settings interface.
Strapi provides two default roles:
- Authenticated: For users who must be logged in to access content.
- Public: For users who can access content without logging in.
Overview of Strapi Data Transfer
The
strapi transfercommand streams data from one Strapi instance to another. It requires strict schema matching, meaning both instances must be exact copies of each other except for the data. By default, it transfers content (entities and relations), files (assets), project configuration, and schemas.Key Constraints:
- Admin users and API tokens are NOT transferred.
- If using SQLite on the destination, other database connections are blocked during the operation.
- Websockets or Socket.io must be temporarily disabled or run on a different port/route, otherwise the command will fail.
- Exactly one remote source (
--from) or destination (--to) must be provided. To transfer between two remote instances, you must route the transfer through a local instance.