> 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/atomico-react.md).

# @atomico/react

Wrapper to use webcomponents in React

{% embed url="<https://github.com/atomicojs/react>" %}

### ¿What is @atomico/react?

It is a Wrapper to eliminate React's own problems when rendering webcomponents, with @atomico/react you can:

1. Using your webcomponent's type declarations in React/Preact
2. Synchronize the events of your webcomponents with React
3. Composition from React using children and slots
4. Use SSR of your webcomponents in React/Preact based environments for example Next.js

### When to use @atomico/react?

We recommend using Atomico/react when looking to support React or Preact from your webcomponents built with Atomico.

{% hint style="success" %}
We also support vue with @atomico/vue
{% endhint %}

### @atomico/react vs other solutions?

With Atomico/react it's really easy to use, example:&#x20;

{% tabs %}
{% tab title="@atomico/react" %}

```tsx
import { auto } from "@atomico/react";
import { MyComponent as _MyComponent } from "./my-component.js";

export const MyComponent = auto( _MyComponent );
```

{% endtab %}

{% tab title="@lit-labs/react" %}

```tsx
import * as React from 'react';
import { createComponent } from '@lit-labs/react';
import { MyComponent as _MyComponent } from './my-component.js';

export const MyComponent = createComponent({
  tagName: 'my-component', //⚠️ requires the tagName
  elementClass: _MyComponent, 
  react: React, //⚠️ requires react module
  events: { //⚠️ requires events
    onactivate: 'activate',
    onchange: 'change',
  },
});
```

{% endtab %}
{% endtabs %}

### Example

```jsx
import { auto } from "@atomico/react";
import { HTMLMyComponent } from "./my-component.js";

export const MyComponent = auto( HTMLMyComponent );
```

{% embed url="<https://codesandbox.io/s/atomico-react-example-cizcy>" %}

### @atomico/exports

We invite you to meet [@atomico/exports](#atomico-exports) to automate the generation of wrappers for your webcomponents

{% content-ref url="/pages/g6COhp5j6qafKr5nJn7Y" %}
[@atomico/exports](/doc/packages/introduction.md)
{% endcontent-ref %}


---

# 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://atomico.gitbook.io/doc/packages/atomico-react.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.
