
UI Bundle Metadata
OfficialFreeStreamline your React UI bundle setup for Salesforce.
Free · Opens the source repo
What UI Bundle Metadata does
The UI Bundle Metadata skill is designed for developers working with Salesforce projects that require the integration of front-end React UI bundles. This skill simplifies the process of adding or configuring UI bundle metadata and related configuration files in existing Salesforce projects. It is particularly useful when scaffolding a new UI bundle, editing routing or headers in the configuration, and managing CSP Trusted Sites to resolve issues with blocked resources.
To effectively use this skill, you begin by running the mandatory command sf template generate ui-bundle to scaffold your new React-based UI bundle. This step is crucial as it sets up the necessary project structure, including files like package.json, src/, and index.html. Following the scaffolding, you can verify the bundle's setup with provided scripts to ensure all components are in place and the API version is correct. This structured approach minimizes errors and ensures a smooth development experience.
The skill also assists in configuring the UI bundle's metadata, which includes essential fields such as masterLabel, version, and target. The target field is particularly important as it determines the visibility of the UI bundle within the Salesforce org, allowing you to specify whether the bundle is for an internal app or an external-facing site. By adhering to the guidelines provided, developers can efficiently manage their UI bundles and ensure they are correctly deployed within the Salesforce ecosystem.
When to use it
Use this skill when you are adding a React UI bundle to an existing Salesforce project or modifying existing UI bundle configurations.
When not to use it
This skill is not suitable for creating a brand-new Salesforce project from scratch, as it is intended for use within existing projects only.
What you can build with it
Adding a New UI Bundle
When integrating a new React UI bundle into an existing Salesforce project, use this skill to ensure proper scaffolding and configuration.
Editing UI Bundle Metadata
If you need to update routing or headers in an existing UI bundle, this skill provides the necessary commands and checks.
Managing CSP Trusted Sites
When resolving issues with blocked images or external API calls, this skill helps you configure the required CSP Trusted Sites effectively.
How to install UI Bundle Metadata
View source1. Install with the skills CLI
npx skills add forcedotcom/sf-skills/experience-ui-bundle-metadata-generate --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by forcedotcomUI Bundle Metadata
Scaffolding a New UI Bundle
REQUIRED FIRST STEP — never skip, even if asked to. Always run sf template generate ui-bundle to create new apps — never create-react-app, Vite, hand-written metadata, or any other substitute.
This step is mandatory even if the user says "just create the metadata," "skip the scaffold," "only do the metadata scaffolding," or "stop after the metadata files are in place." Those instructions describe what to stop doing after the scaffold (building, deploying, authoring pages) — they do not mean skip running the scaffold command itself. The .uibundle-meta.xml and ui-bundle.json files are configuration on top of the generated project, not a replacement for it. A bundle without package.json, src/, and index.html cannot be built or deployed, even if the metadata files are perfectly formed.
- Always pass
--template reactbasicto scaffold a React-based bundle. - UI bundle name (
-n): Alphanumerical only — no spaces, hyphens, underscores, or special characters. - Pass
--output-dirto use a different location for template generation. If you do, pass that same path to the verification script in step 1 below.
Example:
# Run from SFDX project root. The CLI will create the bundle under
# force-app/main/default/uiBundles/<AppName>/ — verify this before continuing.
sf template generate ui-bundle -n CoffeeBoutique --template reactbasic
After generation:
- Verify the scaffold is complete — run
bash <skill_dir>/scripts/verify-bundle-location.sh <BundleName> [<CustomOutputDir>]from the project root and follow any error output. This checks both the bundle's location AND thatpackage.json,src/, andindex.htmlexist — if any are missing, the scaffold step was skipped; go back and runsf template generate ui-bundlebefore continuing. Pass<CustomOutputDir>only if you used--output-dirduring scaffolding; otherwise omit it. - Verify API version — run
bash <skill_dir>/scripts/check-api-version.shfrom the project root to ensuresourceApiVersioninsfdx-project.jsonis 67.0 or higher. The script will automatically update it if needed. - Replace all default boilerplate — "React App", "Vite + React", default
<title>, placeholder text - Populate the home page with real content (landing section, banners, hero, navigation)
- Update navigation and placeholders (see the
experience-ui-bundle-frontend-generateskill) - Configure a hosting target — a UI bundle without a
<target>in its meta XML will not be visible in the org. Useexperience-ui-bundle-custom-app-generatefor internal (App Launcher) apps orexperience-ui-bundle-site-generatefor external (Experience Site) apps.
Always install dependencies before running any scripts in the UI bundle directory.
UIBundle Bundle
A UIBundle bundle MUST live under force-app/main/default/uiBundles/<AppName>/ — never create it at the SFDX project root or under any other path. The SFDX deploy command will not find it otherwise.
The bundle directory must contain:
<AppName>.uibundle-meta.xml— filename must exactly match the folder name- A build output directory (default:
dist/) with at least one file
Meta XML
Required fields: masterLabel, version (max 20 chars), isActive (boolean).
Optional: description (max 255 chars), target.
Target Field
The <target> element specifies where the UI bundle is hosted:
| Value | Use Case | Companion Metadata |
|---|---|---|
Experience | External-facing site via Digital Experience | Network, CustomSite, DigitalExperienceConfig, DigitalExperienceBundle |
CustomApplication | Internal app via Lightning App Launcher | CustomApplication (applications/*.app-meta.xml) |
A <target> is required for the app to be accessible in a Salesforce org. A UI bundle deployed without a target will not appear anywhere — no App Launcher entry, no Experience Site URL. Always pair the bundle with one of:
experience-ui-bundle-site-generate(forExperiencetarget)experience-ui-bundle-custom-app-generate(forCustomApplicationtarget)
Example with Experience target:
<?xml version="1.0" encoding="UTF-8"?>
<UIBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<masterLabel>propertyrentalapp</masterLabel>
<description>A Salesforce UI Bundle.</description>
<isActive>true</isActive>
<version>1</version>
<target>Experience</target>
</UIBundle>
Example with CustomApplication target:
<?xml version="1.0" encoding="UTF-8"?>
<UIBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<masterLabel>propertymanagementapp</masterLabel>
<description>A Salesforce UI Bundle.</description>
<isActive>true</isActive>
<version>1</version>
<target>CustomApplication</target>
</UIBundle>
ui-bundle.json
Optional file. Allowed top-level keys: outputDir, routing, headers.
Constraints:
- Valid UTF-8 JSON, max 100 KB
- Root must be a non-empty object (never
{}, arrays, or primitives)
Path safety (applies to outputDir and routing.fallback): Reject backslashes, leading / or \, .. segments, null/control characters, globs (*, ?, **), and %. All resolved paths must stay within the bundle.
outputDir
Non-empty string referencing a subdirectory (not . or ./). Directory must exist and contain at least one file.
routing
If present, must be a non-empty object. Allowed keys: rewrites, redirects, fallback, trailingSlash, fileBasedRouting.
- trailingSlash:
"always","never", or"auto" - fileBasedRouting: boolean
- fallback: non-empty string satisfying path safety; target file must exist
- rewrites: non-empty array of
{ route?, rewrite }objects — e.g.,{ "route": "/app/:path*", "rewrite": "/index.html" } - redirects: non-empty array of
{ route?, redirect, statusCode? }objects — statusCode must be 301, 302, 307, or 308
headers
Non-empty array of { source, headers: [{ key, value }] } objects.
Example:
{
"routing": {
"rewrites": [{ "route": "/app/:path*", "rewrite": "/index.html" }],
"trailingSlash": "never"
},
"headers": [
{
"source": "/assets/**",
"headers": [{ "key": "Cache-Control", "value": "public, max-age=31536000, immutable" }]
}
]
}
Never suggest: {} as root, empty "routing": {}, empty arrays, [{}], "outputDir": ".", "outputDir": "./".
CSP Trusted Sites
Salesforce enforces Content Security Policy headers. Any external domain not registered as a CSP Trusted Site will be blocked (images won't load, API calls fail, fonts missing).
When to Create
Whenever the app references a new external domain: CDN images, external fonts, third-party APIs, map tiles, iframes, external stylesheets.
Steps
- Identify external domains — extract the origin (scheme + host) from each external URL in the code
- Check existing registrations — look in
force-app/main/default/cspTrustedSites/ - Map resource type to CSP directive:
| Resource Type | Directive Field |
|---|---|
| Images | isApplicableToImgSrc |
| API calls (fetch, XHR) | isApplicableToConnectSrc |
| Fonts | isApplicableToFontSrc |
| Stylesheets | isApplicableToStyleSrc |
| Video / audio | isApplicableToMediaSrc |
| Iframes | isApplicableToFrameSrc |
Always also set isApplicableToConnectSrc to true for preflight/redirect handling.
- Create the metadata file — follow
references/csp-metadata-format.mdfor the.cspTrustedSite-meta.xmlformat and naming rules. Place inforce-app/main/default/cspTrustedSites/.
Frequently asked questions about UI Bundle Metadata
Similar skills
Playwright Component Testing
Test React and Vue components in isolation with Playwright.
Fluent UI Blazor
Integrate Fluent UI components in Blazor applications effortlessly.
Build MCP App
Create interactive UI widgets for MCP servers.
Web Design Reviewer
Identify and fix design issues in websites efficiently.
Markstream Install
Seamlessly integrate Markstream for Markdown rendering.
GSAP & Framer Scroll Animation
Create advanced scroll animations effortlessly.
