> For the complete documentation index, see [llms.txt](https://devowlio.gitbook.io/wp-react-starter/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://devowlio.gitbook.io/wp-react-starter/typescript-development/utils-package.md). Agents can also search and read this documentation through its [MCP server](https://devowlio.gitbook.io/wp-react-starter/~gitbook/mcp).

# Utils package

As we are using a **multi-package-/mono repository** we have the ability and advantage of **modular** package **development**. That means, coding which should be used in multiple plugins can be **outsourced** to an own package. This can also be done for PHP ([`packages/utils/src`](https://devowlio.gitbook.io/wp-react-starter/usage/index/root.md#folder-structure)), but this does not matter here.

{% content-ref url="/pages/-M-Og0bLuyfD9AymnQAG" %}
[Create package](https://devowlio.gitbook.io/wp-react-starter/advanced/create-package.md)
{% endcontent-ref %}

With [`create-wp-react-app create-workspace`](https://devowlio.gitbook.io/wp-react-starter/usage/getting-started.md#create-workspace) a main utils package in [`packages/utils`](https://devowlio.gitbook.io/wp-react-starter/usage/index/root.md#folder-structure) is generated automatically.

## Factories

All of your plugins can use the factories defined in [`packages/utils/lib/factory`](https://devowlio.gitbook.io/wp-react-starter/usage/index/root.md#folder-structure). They do a lot of work for you and implement a high standard for the following topics:

* AJAX / `XMLHttpRequest` handler with predefined interfaces so all your WP REST API endpoints are typed, see also [this](https://devowlio.gitbook.io/wp-react-starter/typescript-development/example-implementations.md#rest-endpoint).
* ReactJS [context](https://reactjs.org/docs/context.html) creation with a single function. That context must be used together with React [hooks](https://reactjs.org/docs/hooks-intro.html).
* [Localization / i18n](https://devowlio.gitbook.io/wp-react-starter/typescript-development/localization.md#localize-typescript)
* Object-orientated class to [consume options](https://devowlio.gitbook.io/wp-react-starter/typescript-development/consume-php-variable.md#predefined-variables) coming from a localized PHP variable.

{% hint style="info" %}
You do not need to call that factories manually because they are consumed automatically in your generated plugin file [`plugins/your-plugin/src/public/ts/utils/index.tsx`](https://devowlio.gitbook.io/wp-react-starter/usage/index/plugin.md#folder-structure). Just use them.

It is recommend to not extend that utils package by yourself. Imagine you want to upgrade to a newer version of WP ReactJS Starter you need to copy & paste all your customizations manually. Create another package!
{% endhint %}
