How to build a Custom Strapi Plugin

This article is a guest post by Anumadu Moses. He wrote this blog post through the Write for the Community program. If you are passionate about everything jamstack, open-source or javascript and want to share, join the writer's guild!


This is a companion discussion topic for the original entry at https://strapi.io/blog/how-to-build-a-strapi-custom-plugin

Hello, I just want to make sure that I am doing this right. I have created a custom plugin using NPM and it automatically created the cointainer/homepage/index. So far it is working locally but when i push to development the plugin wont show there, do I need to do something before it will show? Also I want to reuse the same plugin that I created to multiple project, what is the more efficient way to do this aside from manual copy pasting the code and etc.

Hello, You can make your custom Strapi plugin readily available through NPM. You can make your plugin a Node.js module that can be easily installed using an NPM command. For more on creating NPM packages, check the following [link][(https://docs.npmjs.com/creating-node-js-modules)]. For a hint on the folder structure of Strapi plugins, here is another helpful link Okay. This way you can easily install it using NPM in your other Strapi projects. As for the production issue, It would help if you can provide more details for a clearer understanding but just make sure the path cointainer/homepage/index is inline with what you have in your production environment.

Hi there, thanks for the tutorial. I just have one aspect that I am struggling to understand. Near the end of the tutorial you create the controller for the email plugin in the controller folder of a seemingly random Collection Type. Why was the controller created here? The email plugin doesn’t seem to relate to the Article Collection Type, yet the controller was created in it’s structure. Thanks in advance for any info you can offer.

you can think of it more as a quick fix I used at the time of writing. It does not have to be there. I only needed a route.

You can create a controller from scratch using either of the two options below:

  • Using the CLI strapi generate:controller restaurant.
    Read the CLI documentation for more information.
  • Manually create a JavaScript file in ./api/**/controllers.

Hope this helps.

1 Like

Thank you very much, that clears it up!

Thanks fo advice!

Great article and guide! Thanks for the advice. The material is written quite professionally. And this is not surprising, because the author is a member of the writer’s guild. I know several professional writers who work for this online service https://www.bestessays.com/custom_term_paper.php and are also members of this guild. Therefore, I know that they are experienced professionals who can make quality content in a short time. Very cool of you to share!

1.Create a New Strap Plugin

2.Define the Plugin Logic:
Inside your new plugin directory, you’ll find a config, controllers, models, and other folders. You can define your plugin’s logic in these folders.
In the config folder, you can set up configuration options for your plugin.
The controllers folder is where you can create controllers for your plugin’s API endpoints.
The models folder is used to define data models for your plugin.