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

# Integrate Login Script

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

Your Replit app 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.

## Ask the agent

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

> 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 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. The agent 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 app 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 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 app is most likely reporting `notLoggedIn` before it has finished checking.
