> For the complete documentation index, see [llms.txt](https://atomico.gitbook.io/doc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://atomico.gitbook.io/doc/packages/introduction/wrapper-for-react.md).

# Wrapper for React

Atomico allows distributing webcomponnets with extended react support, automatically creating wrappers for each component and import paths for react.

For this to be possible you must follow the following rules.

## Rules

### 1. The file that declares the customElement must export the customElement.

{% tabs %}
{% tab title="Example 1" %}

```javascript
import {Component} from "./component";
export {Component} from "./component";

customElements.define("my-component", MyComponent);
```

{% endtab %}

{% tab title="Example 2" %}

```javascript
import {c} from "./my-component";

function component(){
    return <host></host>;
}

export const Component = c(c);

customElements.define("my-component", Component);
```

{% endtab %}
{% endtabs %}

### 2. Compile your components using your favorite bundle tool.

### 3. Point via expressions to the files generated by your bundle tool

```
exports ./dist/**/* ./types/**/* --wrappers
```

The result of this process will be:

1. The association of exports for React inside the package.json
2. The creation of the files of use for React, if the component is created with Atomico adds support to types.

## Example

{% embed url="<https://stackblitz.com/edit/atomico-exports-in-a-monorepo-with-atomico-and-react?file=packages%2Fmy-component%2Fsrc%2Felement.tsx,src%2FApp.tsx>" %}


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://atomico.gitbook.io/doc/packages/introduction/wrapper-for-react.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
