You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because the server looks at the `server/src/index.js` file to import your plugin code, you must use the `watch` command otherwise the code will not be transpiled and the server will not be able to find your plugin.
188
+
Because the server looks at the `server/src/index.ts|js` file to import your plugin code, you must use the `watch` command otherwise the code will not be transpiled and the server will not be able to find your plugin.
Copy file name to clipboardExpand all lines: docusaurus/docs/dev-docs/plugins/development/plugin-structure.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,23 +16,23 @@ import InteractivePluginStructure from '@site/src/components/PluginStructure.js'
16
16
17
17
# Plugin structure
18
18
19
-
When [creating a plugin with Plugin SDK](/dev-docs/plugins/development/create-a-plugin), Strapi generates the following boilerplate structure for you in the `./src/plugins/my-plugin` folder:
19
+
When [creating a plugin with Plugin SDK](/dev-docs/plugins/development/create-a-plugin), Strapi generates the following boilerplate structure for you in the `/src/plugins/my-plugin` folder:
20
20
21
21
<InteractivePluginStructure />
22
22
23
23
A Strapi plugin is divided into 2 parts, each living in a different folder and offering a different API:
| Admin panel | Includes what will be visible in the [admin panel](/user-docs/intro) (components, navigation, settings, etc.) |`/admin`|[Admin Panel API](/dev-docs/plugins/admin-panel-api)|
28
-
| Backend server | Includes what relates to the [backend server](/dev-docs/backend-customization) (content-types, controllers, middlewares, etc.) |`/server`|[Server API](/dev-docs/plugins/server-api)|
27
+
| Admin panel | Includes what will be visible in the [admin panel](/user-docs/intro) (components, navigation, settings, etc.) |`admin/`|[Admin Panel API](/dev-docs/plugins/admin-panel-api)|
28
+
| Backend server | Includes what relates to the [backend server](/dev-docs/backend-customization) (content-types, controllers, middlewares, etc.) |`server/`|[Server API](/dev-docs/plugins/server-api)|
29
29
30
30
<br />
31
31
32
32
:::note Notes about the usefulness of the different parts for your specific use case
33
33
-**Server-only plugin**: You can create a plugin that will just use the server part to enhance the API of your application. For instance, this plugin could have its own visible or invisible content-types, controller actions, and routes that are useful for a specific use case. In such a scenario, you don't need your plugin to have an interface in the admin panel.
34
34
35
-
-**Admin panel plugin vs. application-specific customization**: You can create a plugin to inject some components into the admin panel. However, you can also achieve this by creating a `./src/admin/index.js` file and invoking the `bootstrap` lifecycle function to inject your components. In this case, deciding whether to create a plugin depends on whether you plan to reuse and distribute the code or if it's only useful for a unique Strapi application.
35
+
-**Admin panel plugin vs. application-specific customization**: You can create a plugin to inject some components into the admin panel. However, you can also achieve this by creating a `/src/admin/index.js` file and invoking the `bootstrap` lifecycle function to inject your components. In this case, deciding whether to create a plugin depends on whether you plan to reuse and distribute the code or if it's only useful for a unique Strapi application.
The following diagram is interactive: you can click on any file or folder name highlighted in purple to go to the corresponding documentation section.<br/><br/>
12
+
13
+
<preclassName="prism-code">
14
+
<code>
15
+
. <spanclassName="token comment"># root of the plugin folder (e.g., /src/plugins/my-plugin)</span><br/>
16
+
├── <ahref="/dev-docs/plugins/admin-panel-api">admin</a><spanclassName="token comment"># Admin panel part of your plugin.</span><br/>
17
+
│ ├── src<br/>
18
+
│ │ ├── components <spanclassName="token comment"># Contains your front-end components</span><br/>
│ │ │ └── index.ts <spanclassName="token comment"># Contains the default server configuration</span><br/>
39
+
│ │ ├── <ahref="/dev-docs/plugins/server-api#content-types">content-types</a><spanclassName="token comment"># Content-types specific to your plugin</span><br/>
40
+
│ │ │ └── index.ts <spanclassName="token comment"># Loads all the plugin's content-types</span><br/>
41
+
│ │ ├── <ahref="/dev-docs/plugins/server-api#controllers">controllers</a><spanclassName="token comment"># Controllers specific to your plugin</span><br/>
42
+
│ │ │ ├── index.ts <spanclassName="token comment"># Loads all the plugin's controllers</span><br/>
43
+
│ │ │ └── controller.ts <spanclassName="token comment"># Custom controller example. You can rename it or delete it.</span><br/>
44
+
│ │ ├── <ahref="/dev-docs/plugins/server-api#middlewares">middlewares</a><spanclassName="token comment"># Middlewares specific to your plugin</span><br/>
45
+
│ │ │ └── index.ts <spanclassName="token comment"># Loads all the plugin's middlewares</span><br/>
46
+
│ │ ├── <ahref="/dev-docs/plugins/server-api#policies">policies</a><spanclassName="token comment"># Policies specific to your plugin</span><br/>
47
+
│ │ │ └── index.ts <spanclassName="token comment"># Loads all the plugin's policies</span><br/>
48
+
│ │ ├── <ahref="/dev-docs/plugins/server-api#routes">routes</a><spanclassName="token comment"># Routes specific to your plugin</span><br/>
49
+
│ │ │ └── index.ts <spanclassName="token comment"># Contains an example route for the my-controller custom controller example</span><br/>
50
+
│ │ ├── <ahref="/dev-docs/plugins/server-api#services">services</a><spanclassName="token comment"># Services specific to your plugin</span><br/>
51
+
│ │ │ ├── index.ts <spanclassName="token comment"># Loads all the plugin's services</span><br/>
52
+
│ │ │ └── service.ts <spanclassName="token comment"># Custom service example. You can rename it or delete it.</span><br/>
53
+
│ │ ├── <ahref="/dev-docs/plugins/server-api#bootstrap">bootstrap.ts</a><spanclassName="token comment"># Function that is called right after the plugin has registered</span><br/>
54
+
│ │ ├── <ahref="/dev-docs/plugins/server-api#register">destroy.ts</a><spanclassName="token comment"># Function that is called to clean up the plugin after Strapi instance is destroyed</span><br/>
55
+
│ │ ├── <ahref="/dev-docs/plugins/server-api">index.ts</a><spanclassName="token comment"># Entrypoint for the server (back end)</span><br/>
56
+
│ │ └── <ahref="/dev-docs/plugins/server-api#register">register.ts</a><spanclassName="token comment"># Function that is called to load the plugin, before bootstrap.</span><br/>
The following diagram is interactive: you can click on any file or folder name highlighted in purple to go to the corresponding documentation section.<br/><br/>
@@ -64,69 +127,6 @@ export default function InteractivePluginStructure() {
The following diagram is interactive: you can click on any file or folder name highlighted in purple to go to the corresponding documentation section.<br/><br/>
71
-
72
-
<preclassName="prism-code">
73
-
<code>
74
-
. <spanclassName="token comment"># root of the plugin folder (e.g., /src/plugins/my-plugin)</span><br/>
75
-
├── <ahref="/dev-docs/plugins/admin-panel-api">admin</a><spanclassName="token comment"># Admin panel part of your plugin.</span><br/>
76
-
│ ├── src<br/>
77
-
│ │ ├── components <spanclassName="token comment"># Contains your front-end components</span><br/>
│ │ │ └── index.ts <spanclassName="token comment"># Contains the default server configuration</span><br/>
98
-
│ │ ├── <ahref="/dev-docs/plugins/server-api#content-types">content-types</a><spanclassName="token comment"># Content-types specific to your plugin</span><br/>
99
-
│ │ │ └── index.ts <spanclassName="token comment"># Loads all the plugin's content-types</span><br/>
100
-
│ │ ├── <ahref="/dev-docs/plugins/server-api#controllers">controllers</a><spanclassName="token comment"># Controllers specific to your plugin</span><br/>
101
-
│ │ │ ├── index.ts <spanclassName="token comment"># Loads all the plugin's controllers</span><br/>
102
-
│ │ │ └── controller.ts <spanclassName="token comment"># Custom controller example. You can rename it or delete it.</span><br/>
103
-
│ │ ├── <ahref="/dev-docs/plugins/server-api#middlewares">middlewares</a><spanclassName="token comment"># Middlewares specific to your plugin</span><br/>
104
-
│ │ │ └── index.ts <spanclassName="token comment"># Loads all the plugin's middlewares</span><br/>
105
-
│ │ ├── <ahref="/dev-docs/plugins/server-api#policies">policies</a><spanclassName="token comment"># Policies specific to your plugin</span><br/>
106
-
│ │ │ └── index.ts <spanclassName="token comment"># Loads all the plugin's policies</span><br/>
107
-
│ │ ├── <ahref="/dev-docs/plugins/server-api#routes">routes</a><spanclassName="token comment"># Routes specific to your plugin</span><br/>
108
-
│ │ │ └── index.ts <spanclassName="token comment"># Contains an example route for the my-controller custom controller example</span><br/>
109
-
│ │ ├── <ahref="/dev-docs/plugins/server-api#services">services</a><spanclassName="token comment"># Services specific to your plugin</span><br/>
110
-
│ │ │ ├── index.ts <spanclassName="token comment"># Loads all the plugin's services</span><br/>
111
-
│ │ │ └── service.ts <spanclassName="token comment"># Custom service example. You can rename it or delete it.</span><br/>
112
-
│ │ ├── <ahref="/dev-docs/plugins/server-api#bootstrap">bootstrap.ts</a><spanclassName="token comment"># Function that is called right after the plugin has registered</span><br/>
113
-
│ │ ├── <ahref="/dev-docs/plugins/server-api#register">destroy.ts</a><spanclassName="token comment"># Function that is called to clean up the plugin after Strapi instance is destroyed</span><br/>
114
-
│ │ ├── <ahref="/dev-docs/plugins/server-api">index.ts</a><spanclassName="token comment"># Entrypoint for the server (back end)</span><br/>
115
-
│ │ └── <ahref="/dev-docs/plugins/server-api#register">register.ts</a><spanclassName="token comment"># Function that is called to load the plugin, before bootstrap.</span><br/>
0 commit comments