Plugin structure
When creating a plugin with Plugin SDK, Strapi generates the following boilerplate structure for you in the /src/plugins/my-plugin
folder:
- TypeScript-based plugins
- JavaScript-based plugins
The following diagram is interactive: you can click on any file or folder name highlighted in purple to go to the corresponding documentation section.
. # root of the plugin folder (e.g., /src/plugins/my-plugin)
βββ admin # Admin panel part of your plugin.
β βββ src
β β βββ components # Contains your front-end components
β β β βββ Initializer.tsx # Plugin initializer
β β β βββ PluginIcon.tsx # Contains the icon of your plugin in the main navigation
β β βββ pages # Contains the pages of your plugin
β β β βββ App.tsx # Skeleton around the actual pages
β β β βββ HomePage.tsx # Homepage of your plugin
β β βββ translations # Translations files to make your plugin i18n-friendly
β β β βββ en.json
β β βββ utils
β β β βββ getTranslations.ts # getTranslations function to return the corresponding plugin translations
β β βββ index.ts # Main setup of your plugin, used to register elements in the admin panel
β β βββ pluginId.ts # pluginId variable computed from package.tsxon name
β βββ custom.d.ts # Generated types
β βββ tsconfig.build.json
β βββ tsconfig.json # TypeScript compiler options for the admin panel part
βββ dist # Build of the plugin (front end and back end)
βββ node_modules
βββ server # Back-end part of your plugin
β βββ src
β β βββ config
β β β βββ index.ts # Contains the default server configuration
β β βββ content-types # Content-types specific to your plugin
β β β βββ index.ts # Loads all the plugin's content-types
β β βββ controllers # Controllers specific to your plugin
β β β βββ index.ts # Loads all the plugin's controllers
β β β βββ controller.ts # Custom controller example. You can rename it or delete it.
β β βββ middlewares # Middlewares specific to your plugin
β β β βββ index.ts # Loads all the plugin's middlewares
β β βββ policies # Policies specific to your plugin
β β β βββ index.ts # Loads all the plugin's policies
β β βββ routes # Routes specific to your plugin
β β β βββ index.ts # Contains an example route for the my-controller custom controller example
β β βββ services # Services specific to your plugin
β β β βββ index.ts # Loads all the plugin's services
β β β βββ service.ts # Custom service example. You can rename it or delete it.
β β βββ bootstrap.ts # Function that is called right after the plugin has registered
β β βββ destroy.ts # Function that is called to clean up the plugin after Strapi instance is destroyed