# Front-end Integration Overview

Authopia’s widget has few possible options to be displayed

## Fully fledged widget

<figure><img src="/files/epHAARWOx1ZxPnIAV3fX" alt="" width="375"><figcaption></figcaption></figure>

## Button only

<figure><img src="/files/7BrasPcdaWkhHwa1e1dt" alt="" width="375"><figcaption></figcaption></figure>

Its UI and translations are configurable while integrating the widget if needed.&#x20;

{% hint style="info" %}
For **local** development use **PROJECT ID** of your **Sandbox** project in the admin panel, otherwise you would need to set up an HTTPS environment and change localhost to your project's domain for the widget to work properly.
{% endhint %}

As a first step you’ll need to install the package via npm:

```shell
npm install @authopia/widget
```

Next to integrate the widget you need to put this into your frontend code:

* Load the widget component:

```javascript
import { defineCustomElements } from '@authopia/widget/loader';
import '@authopia/widget/dist/authopia-widget/authopia-widget.css';

defineCustomElements(window);
```

* Embed the widget web component

{% code overflow="wrap" %}

```html
<authopia-widget
    email="YOUR EMAIL"
    project-id="PASTE YOUR PROJECT ID HERE"
    text="Register"
/>
```

{% endcode %}

* If you want to bind to onSuccess event:

```javascript
const authopiaWidget = document.querySelector("authopia-widget")
authopiaWidget.onSuccess = function () {
  alert('success');
}
```

* If your project uses typescript you can add `global.d.ts` for better typing:

```typescript
declare namespace JSX {
  import { AuthopiaWidgetElement } from '@authopia/widget';

  interface IntrinsicElements {
    'authopia-widget': AuthopiaWidgetElement;
  }
}
```

After a successful authentication flow an ID token is returned via onSuccess method


---

# Agent Instructions: 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://developers.authopia.io/docs/front-end/front-end-integration-overview.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.
