# Users can't log in after you publish? Here is why, and the fix.

> Why sign-in works in preview and fails on the live site, step by step, and how a hosted sign-in page on your own domain stops it coming back.

Page: https://www.buildbase.app/use-cases/fix-login-after-publish

Preview runs on one address, your live site on another, and the sign-in flow only knows the first. Move sign-in to a hosted page on your own domain and it stops breaking.

**What it is:** BuildBase is one SDK and console for React apps: sign-in, teams, billing, email and roles that work for real users.

Fix my sign-in: https://console.buildbase.app

For your coding agent: Replace this app's hand-built login with BuildBase hosted sign-in and sessions, set up for its live address. Install the skill first: npx skills add buildbase-app/claude-skill

## Why it works in preview and fails on your live site

The same click, twice. The only difference is the address.

| Step | In preview | On your live site |
| --- | --- | --- |
| Someone clicks Sign in with Google | Your app sends them to Google with the preview address as the way back | Your app sends them to Google with the live address as the way back |
| Google checks the way back | The preview address is on its list, so it goes on | The live address was never added, so it stops: redirect_uri_mismatch |
| They come back to your app | Signed in, so it looks finished | An error page, so they leave |
| With a hosted sign-in page | Google sends people back to your sign-in domain | The same sign-in domain, then on to your app's live address, which you set once |

## What your preview never tested

In preview, you are the only user and the only address. The first stranger on the live site finds the rest.

| Without it | Already covered |
| --- | --- |
| A sign-in flow that knows your live domain | One hosted sign-in page on your own domain, so providers send people back to one place |
| Each social provider set up by hand | Google, LinkedIn, GitHub, Microsoft, Apple, Lovable and Vercel sign-in, switched on in the console |
| Sessions you can end from the server | Sign-out that revokes the session on the server, and sign out everywhere in one call |
| Reset and verification emails that arrive | 40+ editable templates, sent from a sender you set up |
| The people who already signed up | Imported with their passwords where the old hash can be checked, so nobody resets |

## Running in production

Running in production on six products today, all of them ours.

- [OnceBooks](https://www.oncebooks.com): Personalised children's books
- [PlugNode](https://plugnode.ai): Visual AI workflow builder
- [AgentCenter](https://www.agentcenter.cloud): Mission control for AI agents
- [Imejis](https://www.imejis.io): Template-based image generation API
- [RemoteWait](https://remotewait.com): Virtual queue system
- [LinkTracer](https://social-link-tracer.jagodana.com): Creator link analytics

## Fix it in three steps

1. **Install the skill.** Your coding agent gets the steps for this fix, in the tool you already use.

```bash
npx skills add buildbase-app/claude-skill
```

2. **Wire the provider.** Wrap your app once, with the live address your users sign in from.

```tsx
import { ApiVersion } from '@buildbase/sdk';
import { SaaSOSProvider } from '@buildbase/sdk/react';

export default function Providers({ children }) {
  return (
    <SaaSOSProvider
      serverUrl="https://api.yourapp.com"
      version={ApiVersion.V1}
      orgId="your-org-id"
      auth={{
        clientId: 'your-client-id',
        redirectUrl: 'http://localhost:3000',
      }}
      locale="en" // en, es, fr, de, ja, zh, hi, ar
    >
      {children}
    </SaaSOSProvider>
  );
}
```

3. **Swap the login button.** Sign-in and sign-out come from the SDK, so there is no login code left to break.

```tsx
import {
  useSaaSAuth,
  WhenAuthenticated,
  WhenUnauthenticated,
} from '@buildbase/sdk/react';

function App() {
  const { user, signIn, signOut, openWorkspaceSettings } = useSaaSAuth();

  return (
    <>
      <WhenUnauthenticated>
        <button onClick={() => signIn()}>Sign In</button>
      </WhenUnauthenticated>

      <WhenAuthenticated>
        <p>Welcome, {user?.name}</p>
        <button onClick={() => openWorkspaceSettings('subscription')}>
          Manage Plan
        </button>
        <button onClick={signOut}>Sign Out</button>
      </WhenAuthenticated>
    </>
  );
}
```


## What replaces the hand-built login

- **Hosted sign-in on your domain.** A sign-in page you never wrote, on your own domain, so a new address does not break login. (Authentication: https://www.buildbase.app/auth)
- **Social sign-in from the console.** Google, LinkedIn, GitHub, Microsoft, Apple, Lovable and Vercel, switched on without touching the app, so each provider is not another redirect to get wrong. (Authentication: https://www.buildbase.app/auth)
- **Passkeys and email links.** People who would rather not use a password sign in with a passkey or a link, from the same page. (Authentication: https://www.buildbase.app/auth)
- **Sessions the server controls.** Sign a user out everywhere in one call, so a leaked session ends when you say it ends. (Authentication: https://www.buildbase.app/auth)
- **Emails from real templates.** Verification, reset and account emails from editable templates, so the first message a user gets arrives. (Email Campaigns: https://www.buildbase.app/email)
- **Your existing users kept.** Import users from Clerk, Auth0, Firebase or Supabase, keeping passwords where the old hash can be checked. (Authentication: https://www.buildbase.app/auth)

## What a sign-in you build yourself costs

Sign-in and the emails around it, built with an AI coding agent and kept working on every address, against having them here.

|  | Build it yourself | BuildBase |
| --- | --- | --- |
| Hours | 55 | 6 |
| Time | about 1.8 weeks | about 1.0 days |
| First year | $5,925 | $550 (Launch, paid yearly) |

Modules: Authentication, Email Campaigns. At $60 an hour. Estimates for a senior developer working with an AI coding agent such as Claude Code or Cursor, tests included. Upkeep covers dependency upgrades, provider API changes, incidents and support. Not a quote. Last reviewed 17 November 2026. Calculator: https://www.buildbase.app/build-vs-buy

## Fixing login does not need a paid plan

The Free plan covers 10,000 monthly active users and stops at its allowance.

| Plan | Monthly | Yearly | Monthly active users | Workspaces |
| --- | --- | --- | --- | --- |
| Free | $0 | $0 | 10,000 | 50 |
| Launch | $19 | $190 | 25,000 | 1,000 |
| Grow | $49 | $490 | 100,000 | 25,000 |
| Scale | $99 | $990 | 500,000 | 100,000 |

Paid plans start with a 7-day free trial, no credit card. Free stops at its allowance and never bills over. Enterprise: Custom, by conversation. Full pricing: https://www.buildbase.app/pricing

## Questions

### Will this fix the error I see right now?

If the error is a redirect or callback mismatch on your live site, moving sign-in to a hosted page on your own domain removes that whole class of problem. You still set your live address once. If the error is in your database rules, that part stays yours.

### Do I have to rebuild my app?

No. You install the SDK, wrap the app in its provider and replace the login button. Your pages, data and design stay as they are.

### I built this with Lovable or Cursor. Does it still work?

Yes, if the app is React: Next.js, Vite, React Router / Remix and TanStack Start. The skill gives your agent the steps.

### What does the fix cost?

Nothing to start. The Free plan covers sign-in for up to 10,000 monthly active users at $0 and stops at its allowance. If you outgrow it, Launch is $19 a month after a 7-day trial with no card.

### When is BuildBase the wrong fix?

If only your database rules are broken, fix those instead: BuildBase is not your database. And if your app must keep working with no outside service, own the code: if BuildBase were unreachable, your sign-in would be too.


## Read more

- [Login that works after you publish: the live-site checklist](https://www.buildbase.app/guides/login-that-works-after-you-publish)
- [Confirmation emails that arrive for strangers, not only you](https://www.buildbase.app/guides/emails-that-arrive-for-an-ai-built-app)
- [Middleware redirect loop after login in the App Router](https://www.buildbase.app/guides/nextjs-middleware-redirect-loop-after-login)
- [The vibe coder's launch checklist](https://www.buildbase.app/guides/vibe-coded-app-launch-checklist)
- [AI-built apps](https://www.buildbase.app/use-cases/ai-built-apps)
- [Secure sign-in for AI apps](https://www.buildbase.app/use-cases/secure-ai-built-apps)
- [Set up with your agent](https://www.buildbase.app/use-cases/coding-agent-setup)
- [All use cases](https://www.buildbase.app/use-cases)
