Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
forcedotcom avatar

Generating Ui Bundle Metadata

  • 1.5k installs
  • 763 repo stars
  • Updated July 24, 2026
  • forcedotcom/afv-library

This is a copy of generating-ui-bundle-metadata by forcedotcom - installs and ranking accrue to the original listing.

generating-ui-bundle-metadata is a Salesforce agent skill that generates correct CSP Trusted Site metadata XML files for external API and image domains used by Lightning Web Components.

About

generating-ui-bundle-metadata automates creation of Salesforce Content Security Policy Trusted Site metadata files at force-app/main/default/cspTrustedSites/{Name}.cspTrustedSite-meta.xml. The skill enforces naming conventions where file names match the fullName element—for example Unsplash_Images.cspTrustedSite-meta.xml for https://images.unsplash.com. Developers reach for generating-ui-bundle-metadata when LWC or Aura components fetch external APIs or images and CSP blocks those requests at deploy time. The skill covers directory placement, fullName-to-filename mapping, and domain-specific metadata patterns for common integrations like Open-Meteo and OpenStreetMap tiles.

  • Generates cspTrustedSite-meta.xml files with correct naming and structure
  • Enforces PascalCase with underscore naming convention for fullName
  • Maps common domains such as Unsplash, Open-Meteo, and OpenStreetMap to proper metadata
  • Includes all required CSP context flags including connect-src, font-src, and img-src
  • Ensures files are placed in the exact force-app/main/default/cspTrustedSites/ directory

Generating Ui Bundle Metadata by the numbers

  • 1,493 all-time installs (skills.sh)
  • +1 installs in the week ending Jul 28, 2026 (Skillselion tracking)
  • Security screen: LOW risk (skills.sh audit)
  • Data as of Jul 28, 2026 (Skillselion catalog sync)
npx skills add https://github.com/forcedotcom/afv-library --skill generating-ui-bundle-metadata

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs1.5k
repo stars763
Security audit3 / 3 scanners passed
Last updatedJuly 24, 2026
Repositoryforcedotcom/afv-library

How do you add CSP Trusted Sites in Salesforce metadata?

Automatically generate correct Salesforce CSP Trusted Site metadata files for external API and image domains.

Who is it for?

Salesforce developers deploying Lightning Web Components that call external REST APIs or load third-party image domains.

Skip if: Non-Salesforce projects or teams managing CSP headers only at the CDN or web-server layer outside Salesforce metadata.

When should I use this skill?

User needs CSP Trusted Site metadata, external API whitelist, or image domain trust for Salesforce UI bundles.

What you get

cspTrustedSite-meta.xml files placed under force-app/main/default/cspTrustedSites/ with matching fullName values.

  • cspTrustedSite-meta.xml metadata files
  • CSP directory structure under force-app/main/default/

Files

SKILL.mdMarkdownGitHub ↗

UI Bundle Metadata

Scaffolding a New UI Bundle

Use sf template generate ui-bundle to create new apps — not create-react-app, Vite, or other generic scaffolds.

Always pass `--template reactbasic` to scaffold a React-based bundle.

UI bundle name (`-n`): Alphanumerical only — no spaces, hyphens, underscores, or special characters.

Example:

sf template generate ui-bundle -n CoffeeBoutique --template reactbasic

After generation: 1. Replace all default boilerplate — "React App", "Vite + React", default <title>, placeholder text 2. Populate the home page with real content (landing section, banners, hero, navigation) 3. Update navigation and placeholders (see the building-ui-bundle-frontend skill) 4. Configure a hosting target — a UI bundle without a <target> in its meta XML will not be visible in the org. Use generating-ui-bundle-custom-app for internal (App Launcher) apps or generating-ui-bundle-site for external (Experience Site) apps.

Always install dependencies before running any scripts in the UI bundle directory.

---

UIBundle Bundle

A UIBundle bundle lives under uiBundles/<AppName>/ and 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:

ValueUse CaseCompanion Metadata
ExperienceExternal-facing site via Digital ExperienceNetwork, CustomSite, DigitalExperienceConfig, DigitalExperienceBundle
CustomApplicationInternal app via Lightning App LauncherCustomApplication (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:

  • generating-ui-bundle-site (for Experience target)
  • generating-ui-bundle-custom-app (for CustomApplication target)

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

1. Identify external domains — extract the origin (scheme + host) from each external URL in the code 2. Check existing registrations — look in force-app/main/default/cspTrustedSites/ 3. Map resource type to CSP directive:

Resource TypeDirective Field
ImagesisApplicableToImgSrc
API calls (fetch, XHR)isApplicableToConnectSrc
FontsisApplicableToFontSrc
StylesheetsisApplicableToStyleSrc
Video / audioisApplicableToMediaSrc
IframesisApplicableToFrameSrc

Always also set isApplicableToConnectSrc to true for preflight/redirect handling.

4. Create the metadata file — follow implementation/csp-metadata-format.md for the .cspTrustedSite-meta.xml format. Place in force-app/main/default/cspTrustedSites/.

Related skills

FAQ

Where do CSP Trusted Site files belong in a Salesforce project?

generating-ui-bundle-metadata places files at force-app/main/default/cspTrustedSites/{Name}.cspTrustedSite-meta.xml. The cspTrustedSites directory must be a direct child of force-app/main/default/.

How must CSP Trusted Site file names match XML content?

generating-ui-bundle-metadata requires the file name to match the fullName element plus .cspTrustedSite-meta.xml—for example fullName Unsplash_Images becomes Unsplash_Images.cspTrustedSite-meta.xml.

Is Generating Ui Bundle Metadata safe to install?

skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

Backend & APIsintegrationsbackend

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.