> ## Documentation Index
> Fetch the complete documentation index at: https://docs.base44.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Base44 platform: Web app, TanStack Start

> source commit is in /SOURCE_COMMIT at the repository root. Edits here are overwritten by

> [!WARNING]
>
> This page is part of an AI coding agent skill and is written for agents, not humans. For the human-readable Base44 docs, see the [developer documentation](https://docs.base44.com/developers).

# Base44 platform: Web app, TanStack Start

\<concepts>
Backend: entities (JSON schemas defining stored data); server functions and server routes (this app's own server code — see the `base44-platform-backend-functions` skill).
Frontend: routes (one React component per file in `src/routes/`, server-rendered by default), components, layouts (route files that render `<Outlet />`).
\</concepts>

\<file\_structure>
TanStack Start project (Vite, built for Cloudflare Workers — never remove or change the plugins in `vite.config.js`); create files anywhere under src/.

* src/routes/... (jsx — one file per route, see the route-file rules in the `base44-platform-frontend` skill's TanStack reference) · src/routes/api/... (js — server routes) · src/lib/server-fns.js (server functions) · src/lib/\*.server.js (server-only code) · src/components/... (jsx, subfolders ok) · base44/entities/... (jsonc) · base44/agents/... (jsonc)
* src/routes/\_\_root.jsx (the HTML document + providers) · src/index.css (design tokens) + tailwind.config.js · src/router.jsx · src/start.js · src/routeTree.gen.ts (generated — never edit)
* Extra dirs as needed (src/lib/, src/hooks/, …). Frontend files use src/ paths; entities/agents use their base44/… paths above; code imports use the @/ alias (never relative src/ paths — they break on moves).

Create, edit and delete files directly at these paths; a change is live once the file is written.
\</file\_structure>

\<authentication>
The platform owns the auth backend (tokens, sessions, email verification) — never implement auth backend logic.
Whether this app is enrolled in custom auth is in the app profile (`custom_auth_enrolled`); the rest of this section applies only when it is enrolled AND its visibility (dashboard: Settings → Access) is public without login. Otherwise the platform provides the login experience — never create a login page.

Boilerplate auth components already exist in `src/components/auth/` — never create, recreate, make parallel versions of, or preemptively rewrite them. If one seems missing from your context, assume it still exists; read the file to confirm before writing one:
`LoginPage` · `RegisterPage` (register → email code → verifyOtp) · `ForgotPasswordPage` · `ResetPasswordPage` (reads `?token=`) · `MfaPage` (two-factor authentication settings and MFA sign-in) · `AuthGate.jsx` (`requireSignedIn`, `AuthGateError`), each in `src/components/auth/<Name>.jsx`, with the shared `AuthLayout`. Fully functional: flows, Google OAuth, OTP, reset, errors, redirects. They ship in English — translate visible strings proactively when the user's language differs.

The boilerplate guarantees the components, not their routes — the starter has no auth routes, and a file under `src/routes/` is live as soon as it exists. As soon as the app gets any auth surface — a login/sign-up entry point, an admin/management/dashboard screen, a gated page, or anything that sends visitors to login — all five route files below must exist: keep every one already there, add the missing ones. All five go in together even when only one of them was asked for, because each page links to the others, the reset email targets `/reset-password` and a Google or SSO sign-in that needs MFA comes back to `/mfa`. Never remove or rewrite an auth route that already exists. Each only wires its component:

```javascript theme={null}
// src/routes/login.jsx — register.jsx (RegisterPage), forgot-password.jsx (ForgotPasswordPage), reset-password.jsx (ResetPasswordPage) and mfa.jsx (MfaPage) follow the same shape
import { createFileRoute } from "@tanstack/react-router";
import { LoginPage } from "@/components/auth/LoginPage";
export const Route = createFileRoute("/login")({ ssr: false, component: LoginPage });
```

Gate authenticated pages with one pathless layout route and put each gated page under `src/routes/_authed/` (`_authed/dashboard.jsx` → `/dashboard`, `_authed/index.jsx` → `/`; the segment adds nothing to the URL):

```javascript theme={null}
// src/routes/_authed.jsx
import { createFileRoute } from "@tanstack/react-router";
import { AuthGateError, requireSignedIn } from "@/components/auth/AuthGate";
export const Route = createFileRoute("/_authed")({ ssr: false, beforeLoad: requireSignedIn, errorComponent: AuthGateError });
```

The gate resolves the session before any child loader runs, sends a signed-out visitor to `/login?returnTo=…` and shows the not-registered screen to a Base44 user who isn't a user of this app; a child reads the visitor with `Route.useRouteContext().user`. Never re-implement the gate inside a page, and never put an auth route under `_authed/`.

Sign-in entry point: a Sign in button calls `useAuth().navigateToLogin()`, which sends the visitor to `/login` and back to the current page; Sign out calls `useAuth().logout()`.

Customize auth pages only on explicit request; edit the components in place; preserve every flow step (register → OTP stays multi-step in any layout — never shortcut OTP with loginViaEmailPassword), the `returnTo` handling: every page resolves a same-origin `returnTo` with `safeReturnTo()` from `src/lib/authReturnTo.js` (falling back to `'/'`) — keep it when editing, never hardcode a bare `'/'` — and the MFA step below.

MFA: when the app requires it, a sign-in returns `mfa_required` instead of a session and the app runs the second step itself with the seeded `MfaFlow`, `MfaManage` and `MfaPage` in `src/components/auth/`: `MfaFlow` (set up an authenticator app with QR code and key, or text messages; then code entry, resend, method switch, remember this device), `MfaManage` (enable, replace or disable a method) and the `/mfa` page (finishes a Google, Microsoft, Facebook, Apple or SSO sign-in that needs the second step and, opened directly, is the two-factor authentication settings page). `MfaFlow` and `MfaManage` are card content: a page shows one with `return <MfaScreen>…</MfaScreen>` (from `MfaParts`) in place of its whole layout, never inside its own card or `AuthLayout`. They run on `@/lib/authMfaFlow` and `@/lib/authMfa`: never edit or re-implement those two or call the MFA API yourself, and never build other MFA screens. Restyle or translate the MFA screens on request, but keep every step, the error handling and the `session-record-block` wrapper, which keeps the QR code, key and codes out of session recordings. Only on request: a link to `/mfa` for managing two-factor authentication (usually from the profile or account page), and a forget-remembered-devices control in `MfaManage` (`session.forgetDevices(code, method)`, confirmed with a code like Disable). Components from before them (`LoginPage` and `RegisterPage` calling `continueMfa` or `base44.auth.loginViaEmailPassword`, `GoogleButton` in `parts.jsx` calling `loginWithGoogle` or `base44.auth.loginWithProvider`) hand MFA to the platform's own page, so the app's MFA screens never show: that is not MFA support. Whenever a request touches MFA (support for it, the MFA screens or their style, sign-in failing after turning MFA on), first make a small targeted edit in `LoginPage`, `RegisterPage` and `parts.jsx` to the calls below and register `/mfa`.

SDK (for template edits):

* Email login: `loginWithMfa(email, password)` from `@/lib/authMfa` (not `base44.auth.loginViaEmailPassword`) — sets token on success; if the result has `mfa_required`, keep it in state and `return <MfaScreen><MfaFlow challenge={result} returnTo={returnTo} /></MfaScreen>` in place of the whole page; else hard redirect to the resolved `returnTo`
* Social and SSO login: `signInWithProvider(provider, returnTo)` from `@/lib/authMfaFlow` — "google"|"facebook"|"microsoft"|"apple"|"sso"; pass the resolved `returnTo`; redirects, and comes back through `/mfa` when MFA is needed. Not `base44.auth.loginWithProvider`, which an MFA-required app rejects
* register(\{email, password}) — does not log in; user unverified. Required: register → OTP → verifyOtp → setToken(access\_token) → hard redirect. Never loginViaEmailPassword right after register — unverified users get a broken session.
* verifyOtp(\{email, otpCode}) — returns access\_token → setToken; or `mfa_required` → `return <MfaScreen><MfaFlow challenge={result} returnTo={returnTo} /></MfaScreen>` in place of the whole page · resendOtp(email)
* resetPasswordRequest(email) — always show generic success (API hides whether email exists) · resetPassword(\{resetToken, newPassword}) — then hard-redirect to `/login`
* isAuthenticated() → Promise\<boolean> · logout(redirectUrl?)
  Hard redirects (window\.location.href), never navigate() — the app must re-initialize with the new session. Auth calls throw: keep the pages' try/catch + inline errors + disabled submit while in-flight (exception: resetPasswordRequest always shows generic success).

Missing component — only after reading the directory confirms it is actually absent (a build error alone never justifies recreation; check first): recreate it at the exact path/name per the rules above, reusing `AuthLayout` and `parts.jsx` in `src/components/auth/` — never "fix" by deleting a route or substituting something simpler.

\</authentication>

\<github\_integration>
Two GitHub features exist: 2-way repo sync, and a GitHub connector (build features on GitHub data). On "GitHub", ask which one before proceeding.
\</github\_integration>

\<invite\_user>
`await base44.users.inviteUser("foo@gmail.com", "user")` invites a user — email + app role "user" or "admin"; confirm which role the user wants.

Public app: admins invite both roles; regular users only role="user". Place the call where only users allowed to grant that role trigger it — unpermitted calls won't work.

\</invite\_user>


## Related topics

- [Base44 Developer Platform](https://docs.base44.com/developers/home.md)
- [Project Structure](https://docs.base44.com/developers/app-code/overview/project-structure.md)
- [Introduction](https://docs.base44.com/developers/app-code/overview/introduction.md)
- [Build apps, websites, and AI agents](https://docs.base44.com/index.md)
- [Backend Functions Overview](https://docs.base44.com/developers/backend/resources/backend-functions/overview.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.