Skip to content

Search is only available in production builds. Try building and previewing the site to test it out locally.

How to Publish a UI Package

In XSite, each UI component is treated as an independent package.
For example:

  • @xsite/ui-cta1
  • @xsite/ui-hero2
  • @xsite/ui-about1

This guide explains the standard workflow for building, versioning, and publishing a single UI component package to the package registry.


Before publishing, ensure:

  • You have created or modified a UI component inside packages/ui
  • Your local environment is set up with pnpm
  • You are authenticated with the package registry (Verdaccio)
  • The component builds successfully

Step 1: Create a Changeset (Required First)

Section titled “Step 1: Create a Changeset (Required First)”

Before building or publishing a component, you must record what changed using Changesets. This ensures proper versioning and release tracking.

Terminal window
npx changeset
  • You will be prompted to select unreleased / changed packages
  • Choose the UI package you modified (e.g., @xsite/ui-cta1)
  • Select the version bump type:
    • major – breaking changes
    • minor – new features
    • patch – fixes or small updates
  • Add a short description of what changed
  • A changeset file will be generated inside .changeset/

After creating the changeset, apply the version bump.

Terminal window
npx changeset version
  • Updates the package version in package.json
  • Updates any dependent packages if required
  • Prepares the repository for publishing

At this point, the package is versioned and ready to publish.


After the changeset is created, build only the modified component package.

Terminal window
pnpm build:component @xsite/ui-[your_component_name]

Example:

Terminal window
pnpm build:component @xsite/ui-cta1
  • Builds the selected UI package (@xsite/ui-cta1)
  • Ensures all internal and external dependencies are properly resolved
  • Produces the distributable output (compiled files ready for publishing)

⚠️ Important: If the build fails, do not proceed to the next steps. Fix all build errors first.


Finally, publish the updated package to the appropriate package registry. Packages can be published to staging (development) or production, depending on the release target.

Terminal window
pnpm publish:pkg:staging @xsite/ui-[your_component_name]

Example:

Terminal window
pnpm publish:pkg:staging @xsite/ui-cta1
Terminal window
pnpm publish:pkg:production @xsite/ui-[your_component_name]

Example:

Terminal window
pnpm publish:pkg:production @xsite/ui-cta1
  • Publish only the specified UI package
  • Do not affect other UI components
  • Use the updated version generated in the previous steps
  • Target the correct registry based on the command:
    • Staging → development/testing environment
    • Production → live environment

If all steps complete successfully:

  • The package is published to Verdaccio
  • The new version becomes available for consumption
  • XSite can now use the updated component at runtime
  • Skipping the build step
  • Publishing without creating a changeset
  • Selecting the wrong version bump type
  • Forgetting to authenticate with Verdaccio