> For the complete documentation index, see [llms.txt](https://avirts-organization.gitbook.io/rocketcode-framework-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://avirts-organization.gitbook.io/rocketcode-framework-documentation/plugins/instruction.md).

# Instruction

## Structure

Every plugin should contain this:

{% code overflow="wrap" %}

```javascript
// plugins/pluginExample.js

// Plugins load automaticly

// Modules
const { renderPage, getAsset, writeRaw, getJson, getRaw } = require('../RocketFramework');
const fs = require('fs');
const path = require('path');

function success() {
    console.warn('ExamplePlugin loaded!') // Just for debug
}

function logic(app) {
    // examplePluginSettings.html

    // Example of handling only "get" requests
    app.get('/plugins/ExamplePlugin/page/ExamplePluginSettings', (req, res) => {
        renderPage('ExamplePluginSettings.html', res); // Here we are rendering page from structure/pages
    });

    // Example of handling only "post" requests
    app.post('/plugins/ExamplePlugin/data/setting', (req, res) => {
      const { name, type, data } = getJson(req); // Use the same order of sending data
      res.send(`Getted setting: ${name}`);
    });
}

// What you must have is below, other for neccessary
module.exports = function (context) {
    // context — object with neccesarry links (conf in route.js) like, app (Express), db and etc.

    // Getting Express.js "router" from router.js
    const app = context.router;

    success();

    logic(app);

    // Same we can use function that we need outside the export for comfort

    // We can use "app" to make new routes to configure something
    // Using the same framework
};
```

{% endcode %}

## 🔙 Previous module

{% content-ref url="/pages/GwgNdHcNEGjuZ7SyPhyh" %}
[Plugins](/rocketcode-framework-documentation/plugins.md)
{% endcontent-ref %}
