# appshare React lane instructions
Use this lane only for advanced appshare mini apps.
## Stack
The regular app-react lane is closed. The app-movil-pwa archetype is a specific approved exception: React + Konsta UI + Tailwind, with the AppShare SDK/React Kit for services and no Bootstrap visual layer. It is installable and requires network; do not add service workers, offline persistence or deferred sync. This exception does not authorize those packages in ordinary React apps.
Allowed:
- React.
- TypeScript.
- Vite.
- Appshare SDK.
- Appshare React Kit.
- Bootstrap 5, themed by appshare.
- React Hook Form.
- Zod.
- TanStack Table.
- TanStack Query.
- React Router only when there are multiple real views.
- Lucide React for icons (bundled as an npm dependency — never from a CDN). For a build-less React app, load appshare's self-hosted set instead: `` and `` / `AppshareIcons.markup("plus")`. Both draw the same Lucide geometry, so the two lanes look identical.
Do not install anything else unless the user explicitly approves an exception.
Forbidden by default:
- MUI.
- Ant Design.
- Chakra.
- Mantine.
- PrimeReact.
- Tailwind.
- shadcn installed per app.
- Radix components installed ad hoc.
- Redux, MobX, Zustand, or another state manager.
- Preact.
- Alpine.
- Random npm component libraries.
## When to use
Use React for:
- Complex local state.
- Master-detail with several nested editors.
- Rich editing.
- Drag/drop.
- Multi-step workflows.
- Reusable interactive components.
- Views where vanilla state would become fragile.
Do not use React for simple CRUD, simple dashboards, or single-form utilities. Use the Bootstrap lane.
## Appshare SDK
Use the SDK for all server calls. Do not hand-code project REST URLs.
```ts
const appshare = Appshare.create({
projectId: "prj_...",
environment: "dev"
});
```
For business logic, prefer project functions:
```ts
const result = await appshare
.function("mis_incidencias_pendientes")
.invoke<{ incidents: Incident[] }>({ limit: 50 });
```
## Reports and shared data queries
Read the topics `/llms/data-queries.txt` ("Data queries and report correctness")
and `/llms/quality.txt` ("Asynchronous app quality") before building or optimizing
a report. Discover existing saved
queries with `list_project_queries` / `get_project_query` before defining a new one.
For Madrid calendar or booking apps, also read `/llms/calendar.txt` and
`/llms/reservations.txt` before implementing date or
reservation behavior. To book Metrica meeting rooms in Outlook, read `/llms/rooms.txt`
("Microsoft 365 meeting rooms"): it is `ctx.rooms`, only inside Project Functions, never Graph from
the browser. To add events to or cancel meetings in an employee's Outlook
calendar, read `/llms/employee-calendars.txt`: it is `ctx.calendar`, also only
inside Project Functions, and the project needs a grant from a platform admin.
Use the same SDK client in this lane:
```js
// Only after confirming this named query exists in the project/environment:
const summary = await appshare.runQuery("orders_by_status", {status: "open"});
const groups = summary.result.rows;
// For detail, choose fields and a bounded page:
const page = await appshare.table("orders").listPage({
fields: ["status", "amount"], limit: 100
});
```
`table.aggregate()` handles SQL counts/sums/groups; Project Functions handle custom
or multi-table rules. `list()` returns a single array page, never all rows. Preserve
`data_revision` when paging; restart on 409. Reuse the summary revision when loading
matching detail. Keep row/field permissions on the server and inspect errors.
Do not download entire tables just to count them. Keep full dates until date cutoffs
are applied. Compare KPIs, history and exports against the current published source;
a successful request or quality job does not establish numeric equivalence.
A separate test app in the same environment shares the original tables, so isolate
write targets for editable tests. Inspect `get_app_quality` after publication and
associate form labels with inputs; review proper-name spelling flags manually.
## Appshare React Kit
Use appshare's React kit before creating local primitives:
- `AppshareProvider`.
- `useAppshare`.
- `Combobox`.
Browser asset shape for no-install prototypes:
```html
```
Bundled apps may import equivalent local copies, but the API surface should stay aligned with this kit.
Initialize the browser kit with the React runtime and the appshare SDK:
```ts
const { AppshareProvider, useAppshare, Combobox } =
AppshareReact.createAppshareReact(React, Appshare);
```
Combobox example:
```tsx
{
const response = await appshare.function("buscar_producto").invoke({ query });
return response.result.products.map((product) => ({
value: product.id,
label: `${product.ean} · ${product.name}`,
meta: product.price
}));
}}
onSelect={(product) => addOrderLine(product)}
/>
```
## UI rules
- Use Bootstrap classes for layout and visual primitives.
- Use Lucide icons (the npm package, or `/sdk/appshare-icons.js` in a build-less app). Do not mix icon families.
- Keep components small and named by domain.
- Use controlled state for editors.
- Keep data fetching in hooks or TanStack Query.
- Validate forms with Zod.
- Do not put business authorization or sensitive filtering only in React; use project functions server-side.
## Master-detail pattern
For an order editor:
- `OrdersPage` owns selected order id and modal open state.
- `OrdersTable` renders the master list.
- `OrderModal` owns the draft order and line editing.
- `ProductCombobox` wraps the Appshare React Kit `Combobox`.
- Save through a project function such as `guardar_pedido`.
- Product lookup through a project function such as `buscar_producto`.
## Dependency policy
If a needed component does not exist:
1. Build it locally using React, Bootstrap, and the Appshare React Kit.
2. If it is generally reusable, add it to the Appshare React Kit.
3. Ask before adding a new package.
The correct default is to extend the platform kit, not to install a one-off library.