> For the complete documentation index, see [llms.txt](https://help.twinr.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.twinr.dev/website-builders/base44/integrate-login-script.md).

# Integrate Login Script

Tell the Twinr app who is signed in on your Base44 app, so notifications reach the right person.

Your Base44 app knows who is signed in. The app does not, unless you tell it. This connects the two, so notifications reach the right person.

You only need this if you send notifications to specific people.

## What works on Base44

Base44 manages authentication for you, and its sign-in screens are not fully customizable. That affects what you can do here:

* **Reporting who is signed in works.** Your app can tell the Twinr app whether someone is signed in, which is what notification targeting needs.
* **Automatic sign-in on return does not.** That needs stable identifiers on your sign-in form, which Base44's managed login screens do not let you set.

In practice this means notifications reach the right person, but someone reopening the app signs in again as they would on the web.

## Ask the AI

With [the MCP server connected](https://help.twinr.dev/website-builders/base44/add-mcp.md), ask Base44:

> Add Twinr login sync to my app. Use the Twinr MCP tools to get what you need.

## What the code does

The AI exposes your sign-in status to the app on a known variable:

```javascript
window.__twinrAuthState // 'loggedIn' | 'notLoggedIn' | 'authError' | 'unknown'
```

The app reads it to know whether someone is signed in, and pairs that with the device token so notifications reach the right person.

{% hint style="warning" %}
**Set `notLoggedIn` only when you are certain nobody is signed in.** While your app is still checking who the user is — on first load, say — the value should stay `unknown`. Reporting `notLoggedIn` too early makes the app treat the person as signed out.
{% endhint %}

## Publish and test

Publish your Base44 app, then:

1. Build your Twinr app and open it on a device.
2. Sign in inside the app.
3. Send a notification aimed at that user from Twinr and confirm it arrives.
