Same SPFx web part needs to work with different lists across sites

Porcaro K 0 Reputation points
2026-12-01T10:46:00.35+00:00

I’m building an SPFx web part that needs to be used on several SharePoint sites, but each site has its own lists and the column names aren’t completely consistent. For example, our HR site and project sites store similar information but use different list names and fields. I’d rather not maintain a separate version of the web part for every site. Is there a practical way to make the list and field mappings configurable for each site?

Microsoft 365 and Office | SharePoint | Development
0 comments No comments

1 answer

Sort by: Oldest
  1. Darren Bruce 3,125 Reputation points Independent Advisor
    2026-12-01T11:16:03.46+00:00

    Dear Porcaro K,

    Yes, it is possible to use the same SPFx web part across multiple SharePoint sites without maintaining separate versions for each site.

    A common approach is to make the web part configurable so that the list name and field mappings can be defined per site rather than hard-coded in the solution.

    For example, instead of directly referencing a specific list and column names in your code, you can define a configuration that maps the web part's expected fields to the actual fields used in each site:

    {
      "listName": "Project Tasks",
      "fields": {
        "title": "TaskName",
        "owner": "AssignedTo",
        "status": "TaskStatus"
      }
    }
    

    The web part would then use the configured mappings when querying data, allowing the same codebase to work with different list schemas.

    Some options you may consider:

    1/SPFx Property Pane Configuration

    • Allow site owners to specify the target list and field names through web part properties.
    • Suitable when configurations differ between web part instances.

    2/Central Configuration List

    • Store site-specific mappings in a SharePoint list.
    • The web part reads the appropriate configuration based on the current site URL.
    • Easier to manage when the solution is deployed across many sites.

    3/Tenant-Wide Configuration

    • Store mappings in SharePoint Tenant Properties, Azure App Configuration, or another central repository.
    • Useful for large-scale deployments across multiple site collections.

    As a best practice, try to use internal field names rather than display names, since display names can be changed by site owners and may cause the web part to break unexpectedly.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.