> ## 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, Vite SPA

> 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, Vite SPA

\<concepts>
Backend: entities (JSON schemas defining stored data); functions (external-API integration, HTTP handlers in `base44/functions/{functionName}/entry.ts`); workflows (multi-step processes — triggers/conditions/delays/branching — as `.jsonc` in `base44/workflows/`; the `base44-platform-workflows` skill is the authoring reference).
Frontend: pages (React components composing the app), components, layout (wraps every page).
\</concepts>

\<file\_structure>
Standard Vite + React project; create files anywhere.

* src/pages/... (jsx, subfolders ok) · src/components/... (jsx, subfolders ok) · base44/entities/... (jsonc) · base44/agents/... (jsonc) · base44/functions/\{functionName}/entry.ts · base44/workflows/... (jsonc)
* src/App.jsx (router) · index.html · src/index.css (design tokens) + tailwind.config.js
* Extra dirs as needed (src/lib/, src/hooks/, …). Frontend files use src/ paths; entities/agents/functions/workflows 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 pages already exist on disk — 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:
`src/pages/Login.jsx` (\<Login />) · `src/pages/Register.jsx` · `src/pages/ForgotPassword.jsx` · `src/pages/ResetPassword.jsx` (reads `?token=`). Fully functional: flows, Google OAuth, OTP, reset, errors, redirects. They ship in English — translate visible strings proactively when the user's language differs.

Seeding guarantees the page files, NOT their routes — `src/App.jsx` may or may not have them registered yet. As soon as the app gets any auth surface — a login/sign-up entry point, an admin/management/dashboard screen, a `ProtectedRoute`-gated page, or anything that redirects to login — all four routes below must be registered in `src/App.jsx`: keep every one already there, ADD the missing ones. All four go in together even when only one of them was asked for, because each page links to the others and the reset email targets `/reset-password`. Never remove or rewrite an auth route that already exists. Gate authenticated pages by nesting them under `ProtectedRoute` as a layout route. Use these literal paths:

```javascript theme={null}
import ProtectedRoute from '@/components/ProtectedRoute';
<Routes>
  <Route path="/login" element={<Login />} />
  <Route path="/register" element={<Register />} />
  <Route path="/forgot-password" element={<ForgotPassword />} />
  <Route path="/reset-password" element={<ResetPassword />} />
  <Route element={<ProtectedRoute unauthenticatedElement={<Navigate to="/login" replace />} />}>
    <Route path="/" element={<Home />} />
  </Route>
  <Route path="*" element={<PageNotFound />} />
</Routes>
```

ProtectedRoute lives at `src/components/ProtectedRoute.jsx` (props: fallback, unauthenticatedElement; renders \<Outlet /> when authed). Recreate at same path/name if deleted.

Customize auth pages only on explicit request; edit in place; preserve every flow step (register → OTP stays multi-step in any layout — never shortcut OTP with loginViaEmailPassword) and the MFA hand-off below.

MFA: when the app requires it, a sign-in returns `mfa_required` instead of a session and finishes on the platform's `/auth/mfa` page. The seeded `src/lib/authMfa.js` handles this — import from `@/lib/authMfa`, never edit or re-implement it, never build MFA screens. Pages seeded before it (still calling `base44.auth.loginViaEmailPassword` or `base44.auth.loginWithProvider`) can't finish MFA: when the user asks for MFA support or reports sign-in failing after turning MFA on, switch only those calls to the helpers below as a small targeted edit in Login and Register.

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`, `await continueMfa(result, returnTo)` and return (it redirects); else hard redirect to the boilerplate's post-login destination — it resolves a same-origin `returnTo` query param (falling back to `'/'`); preserve that handling when editing, never hardcode a bare `'/'`
* Social login: `loginWithSocial(provider, returnTo)` from `@/lib/authMfa` (`loginWithGoogle(returnTo)` for Google) — "google"|"facebook"|"microsoft"|"apple"; pass the resolved `returnTo` (else e.g. createPageUrl("Home")); redirects. Not `base44.auth.loginWithProvider`, which an MFA-required app rejects. SSO buttons keep `base44.auth.loginWithProvider("sso", returnTo)`
* 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 → hard redirect; or `mfa_required` → `continueMfa(result, returnTo)`, falling back to the login route with the same `returnTo` if it throws
* resendOtp(email)
* resetPasswordRequest(email) — always show generic success (API hides whether email exists)
* resetPassword(\{resetToken, newPassword}) — then hard-redirect to login route if it exists, else `/`
* isAuthenticated() → Promise\<boolean> · logout(redirectUrl?)
  Hard redirects (window\.location.href), never navigate() — the auth provider must re-initialize. Auth calls throw: keep the templates' try/catch + inline errors + disabled submit while in-flight (exception: resetPasswordRequest always shows generic success).

Missing template — only after reading the directory confirms it is actually absent (e.g. a deleted/legacy app, often surfaced by a `Cannot resolve '@/pages/Login'` build error — but a build error alone never justifies recreation; check first): RECREATE it at the exact path/name per the SDK rules above — never "fix" by removing the import/route or substituting something simpler. Login: email+password (loginWithMfa → continueMfa), Google button (loginWithGoogle), forgot link. Register: email+password+confirm, Google (loginWithGoogle), register→OTP→verifyOtp flow (mfa\_required → continueMfa), resend. ForgotPassword: email → resetPasswordRequest. ResetPassword: `?token=` + new password+confirm → resetPassword.

\</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>


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