> 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/lovable/integrate-login-script.md).

# Integrate Login Script

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

Your Lovable site knows who is signed in. The app does not, unless you tell it. This connects the two, so notifications reach the right person and the app can keep someone signed in between visits.

You only need this if you send notifications to specific people. For notifications that go to everyone, skip it.

## Ask the agent

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

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

## What the code does

The agent exposes your site's 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.

It also gives your sign-in form stable identifiers, so the app can fill it in when someone returns.

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

## Test it

1. Build your app and open it on a device.
2. Sign in on your site inside the app.
3. Close the app fully and reopen it. You should still be signed in.

If you are signed out each time, your site is most likely reporting `notLoggedIn` before it has finished checking.
