Appearance
React Basic Example
The reference app lives in examples/react-basic. It is a compact React app that keeps the SDUI wiring, fake backend, screen payloads, app-owned components, and form integration in separate files.
Live demo: React Basic.
Run it from the repository root:
bash
pnpm --filter @sdui-kit/react-basic devBuild it:
bash
pnpm --filter @sdui-kit/react-basic buildType-check it:
bash
pnpm --filter @sdui-kit/react-basic typecheckFile Structure
src/App.tsxassemblescreateScreenStore,ActionRunner,SDUIScreenProvider,SDUIScreenRenderer, navigation, and toast state.src/demoData.tscontains the demo application types, seed data, and helpers for reading and creating applications.src/demoBackend.tsis the fake backend. It parses routes, implements theScreenLoader, handles submit requests, and returns screen responses.src/screens.tsbuilds the SDUI payloads for/applications,/applications/:id, and/applications/new.src/registry.tsmaps SDUIcomponentNamevalues to app-owned React components withcreateReactRegistry.src/components/layout.tsxcontains shell, toolbar, page header, section, and card primitives.src/components/application.tsxcontains stats, list, item, badge, and detail components for the application domain.src/components/form.tsxadapts@sdui-kit/formsto React field components and submit handling.src/components/primitives.tsxcontains reusable button, text, heading, empty, and loading pieces.
What It Demonstrates
- App-owned React components registered through
createReactRegistry. - A fake
ScreenLoaderthat returns route-driven SDUI screen payloads. - List, details, and not-found screens selected by route context.
- A server-driven form with validation and conditional company fields.
- Submit through
ActionRunner.request, followed by toast feedback and navigation to the created application. - Refresh through the screen store without changing the current route.