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

# Plugins

EzyTables now supports a plugin system that allows developers to extend the functionality of the library. This feature provides a flexible way to customize and enhance the behavior of EzyTables.

EzyTables now supports a plugin system that allows developers to extend the functionality of the library. This feature provides a flexible way to customize and enhance the behavior of EzyTables according to specific project requirements.

**Plugin Interface**

Each plugin must adhere to a specific interface, ensuring a consistent structure across all plugins. The interface includes the following properties:

* name: A unique identifier for the plugin.
* field: Specifies the field(s) the plugin should be applied to. It can be a string (for a single field) or an array of strings (for multiple fields).
* transform: A function that takes in data and returns transformed data. This function is where the main logic of the plugin resides.

```typescript
interface Plugin {
  name: string;
  field: string | string[];
  transform: (data: any) => any;
}
```

#### Registering Plugins

\
Plugins are registered when an EzyTables instance is created. The constructor of the EzyTables class accepts an array of plugins as an optional parameter. These plugins are then stored and applied during the table rendering process.

#### Applying Plugins

\
During the table rendering process, each plugin is applied to its specified field(s). If the field matches the one specified in the plugin, the transform function of the plugin is called with the field's value.

#### Example Usage

\
Here's an example of how a developer could use this system to register a date formatting plugin that only applies to the 'date' field:

```javascript
const dateFormatPlugin: Plugin = {
  name: 'dateFormat',
  field: 'date',
  transform: (dateString: string) => {
    const date = new Date(dateString);
    return date.toLocaleDateString();
  },
};

const easyTable = new EasyTables({plugins: [dateFormatPlugin]});
```

This plugin will now only be applied to the `date` field when the table is rendered, transforming the date string into a more readable format.

The plugin feature in EzyTables provides a powerful way to customize the behavior of the library, making it even more flexible and adaptable to various use cases.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://carloss-organization-8.gitbook.io/easytables/advanced/plugins.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
