building-webapp-react-components
React Web App (Components, Pages, Layout)
Use this skill whenever you are editing React/TSX code in the web app (creating or modifying components, pages, header/footer, or layout).
Step 1 — Identify the type of component
Determine which of these three categories the request falls into, then follow the corresponding section below:
- Page — user wants a new routed page (e.g. "add a contacts page", "create a dashboard page", "add a settings section")
- Header / Footer — user wants a site-wide header, footer, nav bar, or page footer that appears on every page
- Component — everything else: a widget, card, table, form, dialog, or other UI element placed within an existing page
If it is not immediately clear from the user's message, ask:
"Are you looking to add a new page, a site-wide header or footer, or a component within an existing page?"
Then follow the matching section.
Clarifying Questions
Ask one question at a time and wait for the response before asking the next. Stop when you have enough to build accurately — do not guess or assume.
For a Page
- What is the name and purpose of the page? (e.g., Contacts, Dashboard, Settings)
- What URL path should it use? (e.g.,
/contacts,/dashboard) — or derive from the page name? - Should the page appear in the navigation menu?
- Who can access it? Public, authenticated users only (
PrivateRoute), or unauthenticated only (e.g., login —AuthenticationRoute)? - What content or sections should the page include? (list, form, table, detail view, etc.)
- Does it need to fetch any data? If so, from where?
For a Header / Footer
- Header, footer, or both?
- What should the header contain? (logo/app name, nav links, user avatar, CTA button, etc.)
- What should the footer contain? (copyright text, links, social icons, etc.)
- Should the header be sticky (fixed to top while scrolling)?
- Is there a logo or brand name to display? (or placeholder?)
- Any specific color scheme or style direction? (dark background, branded primary color, minimal, etc.)
- Should navigation links appear in the header? If so, which pages?
For a Component
- What should the component do? (display data, accept input, trigger an action, etc.)
- What page or location should it appear on?
- Is this shared/reusable across pages, or specific to one feature? (determines file location)
- What data or props does it need? (static content, props, fetched data)
- Does it need internal state? (loading, toggle, form state, etc.)
- Are there any specific shadcn components to use? (Card, Table, Dialog, Form, etc.)
- Should it appear in a specific layout position? (full-width, sidebar, inline, etc.)
Implementation
Once you have identified the type and gathered answers to the clarifying questions, read and follow the corresponding implementation guide:
- Page — read
implementation/page.mdand follow the instructions there. - Header / Footer — read
implementation/header-footer.mdand follow the instructions there. - Component — read
implementation/component.mdand follow the instructions there.
TypeScript Standards
- Never use
any— use proper types, generics, orunknownwith type guards. - Event handlers:
(event: React.FormEvent<HTMLFormElement>): void - State:
useState<User | null>(null)— always provide the type parameter. - No unsafe assertions (
obj as User). Use type guards:function isUser(obj: unknown): obj is User { return typeof obj === 'object' && obj !== null && typeof (obj as User).id === 'string'; }
Verification (MANDATORY)
Before completing, run from the web app directory force-app/main/default/webapplications/<appName>/:
cd force-app/main/default/webapplications/<appName> && npm run lint && npm run build
- Lint: MUST result in 0 errors.
- Build: MUST succeed (includes TypeScript check).
If either fails, fix the errors and re-run. Do not leave the session with failing quality gates.