forcedotcom/sf-skills / plugins/builder/experience-react/skills/experience-ui-bundle-frontend-generate
experience-ui-bundle-frontend-generate
VerifiedMUST activate before editing ANY file under uiBundles/*/src/ (or the bundle's index.html) for visual or UI changes to an EXISTING app — pages, components, sections, layout, styling, colors, fonts, navigation, animations, branding, or any look-and-feel change. Use this skill when modifying pages, components, layout, styling, navigation, or branding in an existing UI bundle app. Activate when the project contains appLayout.tsx, routes.tsx, src/pages/, src/components/, src/styles/global.css, or the bundle's index.html. This skill contains critical project-specific conventions (appLayout.tsx shell, shadcn/ui components, Tailwind CSS, Salesforce base-path routing, module restrictions) that override general knowledge. Without this skill, generated code will use wrong imports, break routing, or ignore project structure. Do NOT use when creating a new app from scratch or the bundle has not been scaffolded yet (use experience-ui-bundle-app-coordinate instead).
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 14.5 KB |
| references/component.md | markdown | 6.2 KB |
| references/header-footer.md | markdown | 5.7 KB |
| references/page.md | markdown | 5.5 KB |
| scripts/check-preconditions.mjsexecutable | script | 2.3 KB |
| scripts/resolve-ui-bundle.mjsexecutable | script | 2.5 KB |
| scripts/verify-rules.mjsexecutable | script | 3.3 KB |
references/page.md
View on GitHub# Implementation — Page
### Rules
1. **Edit the component that owns the UI, never output raw HTML** — When editing the home page or any page content, modify the actual `.tsx` file that renders the target. If the target is inside a child component (e.g. `<GlobalSearchInput />` in `Home.tsx`), edit the child's file (e.g. `GlobalSearchInput.tsx`), not the parent. Do not wrap the component with extra elements in the parent; go into the component and change its JSX. Do not paste or generate raw HTML.
2. **`routes.tsx` is the only route registry** — never add routes in `app.tsx` or inside page files.
3. **All pages are children of the AppLayout route** — do not create top-level routes that bypass the layout shell.
4. **Default export per page** — each page file has exactly one default-export component.
5. **Path aliases in all imports** — use `@/pages/...`, `@/components/...`; no deep relative paths.
6. **No inline styles** — Tailwind utility classes and design tokens only.
7. **Catch-all last** — `path: '*'` (NotFound) must always remain the last child in the layout route.
8. **Never modify `appLayout.tsx`** when adding a page — layout changes are a separate concern.
9. **Search-results pages render the installed search feature** — when a search feature is installed (via `experience-ui-bundle-features-generate`), mount its shipped `<Search>` at the results route. Do **not** query data directly (a custom `SearchResults.tsx` against seed data or a raw GraphQL call) — that bypasses the installed feature so the deployed sObject/CMS search never runs. A custom results UI is fine *only if it's built on the feature's `useSearch` hook*, or when the user explicitly opted out of OOTB search (confirm, don't infer). See the feature's README: get the `Package:` name from `npx @salesforce/ui-bundle-features describe <feature>`, then run `npm view <package> readme`.
### Step 1 — Create the page file
Create `src/pages/MyPage.tsx` with a **default export** and the standard page container:
```tsx
export default function MyPage() {
return (
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
<h1 className="text-3xl font-bold text-foreground">My Page</h1>
<p className="mt-4 text-muted-foreground">Page content goes here.</p>
</div>
);
}
```
Use shadcn components from `@/components/ui` for UI elements. All styling via Tailwind — no inline `style={{}}`.
### Step 2 — Register the route in `routes.tsx`
Open `src/routes.tsx`. Import the page and add it inside the layout route's `children` array:
```tsx
import MyPage from "@/pages/MyPage";
// Inside the layout route's children array (before the catch-all):
{
path: "my-page",
element: <MyPage />,
handle: { showInNavigation: true, label: "My Page" },
},
```
- `path` is a **relative segment** (e.g., `"contacts"`), not an absolute path.
- Include `handle: { showInNavigation: true, label: "Label" }` only if the page should appear in the navigation menu.
- The catch-all `path: '*'` must stay **last**.
### Step 3 — Apply an auth guard (if needed)
| Access type | Guard | Behavior |
| ---------------------------------- | ----------------------- | --------------------------------------- |
| Public | None | Direct child of layout |
| Authenticated only | `<PrivateRoute>` | Redirects to login if not authenticated |
| Unauthenticated only (e.g., login) | `<AuthenticationRoute>` | Redirects away if already authenticated |
Example — private page:
```tsx
import { PrivateRoute } from "@/components/auth/private-route";
{
path: "settings",
element: <PrivateRoute><SettingsPage /></PrivateRoute>,
handle: { showInNavigation: true, label: "Settings" },
},
```
Use `ROUTES.*` constants from `@/utils/authenticationConfig` for auth-related paths — do not hardcode `/login`, `/profile`, etc.
### File Conventions — Page
| Concern | Location |
| ----------------- | ------------------------------------------------------ |
| Page component | `src/pages/<PageName>.tsx` (default export) |
| Route definition | `src/routes.tsx` only |
| Layout shell | `src/appLayout.tsx` — do not modify for page additions |
| Auth config paths | `ROUTES.*` from `@/utils/authenticationConfig` |
### State and Data
- **Local state:** `useState`, `useReducer`, `useRef` inside the page component
- **Shared or complex state:** extract to `src/hooks/` with a `use` prefix (e.g., `useContacts`)
- **Data fetching:** any Salesforce record access — GraphQL or REST — goes through the `@salesforce/platform-sdk` Data SDK (`createDataSDK()`, then `sdk.graphql`/`sdk.fetch`). **You MUST invoke the `experience-ui-bundle-salesforce-data-access` skill before writing this code** — do not call `fetch`/`axios` directly or invent a different data API, even if the data need is small or implied only by a clarifying-question answer. Place client/query modules in `src/api/`; place shared data logic (loading, error, caching state) in `src/hooks/`
- **Auth context:** `useAuth()` from `@/context/AuthContext` when current user is needed — only valid under `AuthProvider`
### Confirm — Page
- The page renders inside the app shell (header/nav visible)
- If `showInNavigation: true`, the link appears in the navigation menu
- No TypeScript errors; no broken imports; no missing exports
- Imports use path aliases (`@/`, not deep relative paths)
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |