experience-ui-bundle-metadata-generate
forcedotcom/sf-skills
Configure UI bundle metadata and CSP settings when adding React or Angular bundles to existing Salesforce projects.
What is experience-ui-bundle-metadata-generate?
This skill scaffolds and configures UI bundle metadata files (`.uibundle-meta.xml`, `ui-bundle.json`) and CSP Trusted Sites when adding a new React or Angular UI bundle to an existing SFDX project. Use it when adding a bundle to a project that already exists, not when creating a brand-new Salesforce project from scratch.
- Scaffold new UI bundles using `sf template generate ui-bundle` with framework detection (React or Angular)
- Generate and configure `.uibundle-meta.xml` metadata files with required fields (masterLabel, version, isActive, target)
- Create and edit `ui-bundle.json` configuration for routing, headers, and output directories
- Register CSP Trusted Sites and resolve blocked images, fonts, or external API calls via `cspTrustedSites/*.cspTrustedSite-meta.xml`
- Verify bundle structure, API version compatibility (67.0+), and boilerplate replacement
- Configure hosting targets (Experience for external sites or CustomApplication for internal apps)
How to install experience-ui-bundle-metadata-generate
npx skills add https://github.com/forcedotcom/sf-skills --skill experience-ui-bundle-metadata-generate- Existing SFDX project with Salesforce CLI (sf) 2.0.0 or higher
- Node.js and npm installed for dependency management
- API version 67.0 or higher in sfdx-project.json
- jq 1.6.0 or higher for JSON processing in scripts
How to use experience-ui-bundle-metadata-generate
- 1.Run `bash <skill_dir>/scripts/detect-framework.sh [<ROOT>]` to identify the framework (React or Angular) of your bundle or project
- 2.Execute `sf template generate ui-bundle` with the detected framework and desired bundle name (alphanumeric only)
- 3.Run `bash <skill_dir>/scripts/verify-bundle-location.sh <BundleName> [<CustomOutputDir>] [<framework>]` to confirm the scaffold is complete
- 4.Run `bash <skill_dir>/scripts/check-api-version.sh` to verify and update sourceApiVersion to 67.0+ if needed
- 5.Edit the generated `.uibundle-meta.xml` to set masterLabel, version, isActive, and target (Experience or CustomApplication)
- 6.Configure `ui-bundle.json` with outputDir, routing, and headers as needed
- 7.Register CSP Trusted Sites by editing `cspTrustedSites/*.cspTrustedSite-meta.xml` to unblock external resources
- 8.Use `experience-ui-bundle-custom-app-generate` or `experience-ui-bundle-site-generate` to pair the bundle with its hosting target
Use cases
- Adding a second or additional React/Angular UI bundle to an existing SFDX project
- Editing routing, headers, or output directory settings in an existing bundle's configuration
- Registering external domains in CSP Trusted Sites to unblock images, fonts, or API calls
- Updating `.uibundle-meta.xml` metadata after initial bundle generation
- Configuring a UI bundle to deploy as either an internal Lightning app or external Experience Site
- Salesforce developers building multi-bundle experiences
- Frontend engineers integrating React or Angular apps into Salesforce orgs
- Developers resolving CSP (Content Security Policy) violations in UI bundles
- Teams adding new UI bundles to existing SFDX projects
experience-ui-bundle-metadata-generate FAQ
Use this skill when adding a UI bundle to an EXISTING SFDX project. Use experience-ui-bundle-project-generate only when creating a brand-new Salesforce project entirely from scratch, where the whole starter project (UI bundle, Experience Site metadata, and toolchain) is generated in one step.
No. The scaffold is mandatory even if you only need metadata configuration. The `.uibundle-meta.xml` and `ui-bundle.json` files are configuration on top of the generated project structure (package.json, src/, index.html), not a replacement for it. A bundle without these files cannot be built or deployed.
The target field specifies where the UI bundle is hosted: use 'Experience' for external-facing Digital Experience Sites, or 'CustomApplication' for internal Lightning App Launcher apps. A target is required for the app to be accessible in the org; without it, the bundle will not appear anywhere.
Register the external domain in CSP Trusted Sites by editing or creating `cspTrustedSites/*.cspTrustedSite-meta.xml` files. This unblocks images, fonts, and external API calls that would otherwise be blocked by the browser's content security policy.
React and Angular. The skill detects the framework automatically via `detect-framework.sh` and uses framework-specific reference files. If detection is ambiguous or unknown, you will be prompted to choose from the available options.
Full instructions (SKILL.md)
Source of truth, from forcedotcom/sf-skills.
name: experience-ui-bundle-metadata-generate description: "Use this skill when adding a front-end React or Angular UI bundle to an EXISTING SFDX project, or configuring UI bundle metadata and config files. TRIGGER when: adding or scaffolding a new UI bundle — including adding one more or another UI bundle — into a project that already exists; scaffolding a single bundle with the basic template (reactbasic or angularbasic) via sf template generate ui-bundle; editing ui-bundle.json routing, headers, or output directory; working with .uibundle-meta.xml files; or registering CSP Trusted Sites, resolving blocked images or fonts or external API calls, or editing cspTrustedSites/.cspTrustedSite-meta.xml files. DO NOT TRIGGER when: creating a brand-new Salesforce project entirely from scratch, where the whole SFDX starter project (UI bundle plus Experience Site metadata and toolchain) is generated together in one step (use experience-ui-bundle-project-generate)." metadata: version: "1.3" domains: ["Experience"] minApiVersion: "67.0" relatedSkills: - "experience-ui-bundle-custom-app-generate" - "experience-ui-bundle-frontend-generate" - "experience-ui-bundle-project-generate" - "experience-ui-bundle-site-generate" cliTools: - tool: ["jq"] semver: ">=1.6.0" - tool: ["sf"] semver: ">=2.0.0"
UI 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 a framework CLI (create-react-app, Vite, Angular CLI), 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 an entry index.html cannot be built or deployed, even if the metadata files are perfectly formed.
Determine the framework
The frameworks this skill supports are exactly the reference files under <skill_dir>/references/, each named <framework>-metadata-generate.md (react, angular, …). This is the single source of truth — adding a framework means adding a reference file, nothing here changes.
Detect the framework deterministically — run the script:
bash <skill_dir>/scripts/detect-framework.sh [<ROOT>]
ROOT defaults to the current directory; pass the bundle or project root when editing/configuring an existing bundle. The script prints exactly one token and sets a matching exit code — branch on it:
react/angular(exit 0) — open<skill_dir>/references/<framework>-metadata-generate.mdand use it.ambiguous(exit 2, both frameworks present) — ask the user which one, then use that reference.unknown(exit 3, no signals — e.g. scaffolding a brand-new bundle into a project that has none yet) — fall back to the calling context or the user's stated framework; if still undecided, list<skill_dir>/references/, derive the supported set by stripping the-metadata-generate.mdsuffix from each filename, and ask the user to pick.
If the calling context or the user already named the framework, that overrides detection — but still confirm a matching reference file exists. Never guess.
The reference file gives you the exact --template flag, the entry-file layout, and the default boilerplate strings to replace for that framework.
- 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.
After generation:
- Verify the scaffold is complete — run
bash <skill_dir>/scripts/verify-bundle-location.sh <BundleName> [<CustomOutputDir>] [<framework>]from the project root and follow any error output. This checks both the bundle's location AND thatpackage.json,src/, and an entryindex.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 (pass""to skip it while still supplying a framework); pass<framework>(reactorangular) so the remediation hint uses the right template. - 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 — the framework reference file lists the exact stock
<title>and placeholder strings to replace - 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/.
Related skills
More from forcedotcom/sf-skills and the wider catalog.

experience-ui-bundle-mfa-configure
Configure Multi-Factor Authentication for Salesforce Experience Site users.

experience-ui-bundle-project-generate
Generate a ready-to-develop Salesforce UI bundle starter project from template instead of hand-scaffolding.

experience-ui-bundle-salesforce-data-access
Wire Salesforce data to UI bundle components using the @salesforce/platform-sdk GraphQL API.

experience-ui-bundle-site-generate
Create and configure Salesforce Digital Experience Sites for hosting React UI bundles.

external-diagram-mermaid-generate
Generate Salesforce architecture diagrams in Mermaid with ASCII fallback for docs and terminals.

fetching-salesforce-docs
Retrieve and ground answers in official Salesforce documentation from developer.salesforce.com, help.salesforce.com, and other Salesforce-owned sources.