SharePoint Data Handling with PnP Batching Queries

Updating a thousand SharePoint list items one request at a time is slow and burns through API throttling limits fast. PnPjs batching bundles multiple operations into a single HTTP call instead — here’s the syntax for both the older and current versions of the library, and the real limit worth knowing before you rely on it.


In this post: Old vs. new PnPjs batching syntax · A React example · The real batch size limit · Tradeoffs · When would you actually use this? · Related reading


Old vs. new PnPjs batching syntax
FeatureOlder PnPjs (v2 and below)Current PnPjs (v3+)
Batching syntaxsp.createBatch()spfi().usingBatch()
Execution styleManual .execute() call requiredAutomatic once the batched function’s promises resolve
Adding to the batchExplicit .inBatch(batch) per callImplicit — everything inside the batched instance is included

Older PnPjs (v2 and below):

import { sp } from "@pnp/sp";

async function batchUpdateOld() {
    const batch = sp.createBatch();
    const list = sp.web.lists.getByTitle("MyList");

    for (let i = 1; i <= 5; i++) {
        list.items.getById(i).inBatch(batch).update({ Title: `Updated Item ${i}` });
    }

    await batch.execute();
    console.log("Batch update complete!");
}

Current PnPjs (v3+):

import { spfi } from "@pnp/sp";
import "@pnp/sp/items";

async function batchUpdateNew() {
    const sp = spfi().usingBatch();
    const list = sp.web.lists.getByTitle("MyList");

    for (let i = 1; i <= 5; i++) {
        await list.items.getById(i).update({ Title: `Updated Item ${i}` });
    }

    console.log("Batch update complete!");
}

The v3 version reads like it's making 5 sequential awaited calls, but it isn't -- everything issued against a .usingBatch() instance gets queued and sent together, with the individual awaits resolving once the batch response comes back. It's cleaner to read but easy to misjudge if you're not aware of what's happening underneath.


A React example
import React, { useEffect } from "react";
import { spfi } from "@pnp/sp";
import "@pnp/sp/items";

const BatchUpdateComponent = () => {
    useEffect(() => {
        async function updateItems() {
            const sp = spfi().usingBatch();
            const list = sp.web.lists.getByTitle("MyList");

            for (let i = 1; i <= 5; i++) {
                await list.items.getById(i).update({ Title: `Updated Item ${i}` });
            }

            console.log("Batch update completed in React!");
        }

        updateItems();
    }, []);

    return 
Updating SharePoint List...
; }; export default BatchUpdateComponent;

The real batch size limit

SharePoint's REST $batch endpoint caps out at 100 requests per batch -- worth knowing as an actual number rather than a vague "you might hit limits." You don't have to manage this split yourself, though: PnPjs handles it internally. Queue 1,000 operations into one batch instance and execute it, and the SDK automatically breaks it into 10 sub-batches of 100, sent sequentially as separate network calls -- not one giant request, and not 1,000 individual ones either. That sequential (not parallel) execution of sub-batches is the real performance ceiling worth knowing about: batching helps enormously going from 1,000 requests to 10, but it isn't free past that point.


SharePoint's REST $batch endpoint caps out at 100 requests per batch -- PnPjs auto-splits anything larger into sequential sub-batches, not one giant request.

Tradeoffs

Batching genuinely reduces network round-trips and helps you stay under SharePoint's API throttling thresholds -- real, meaningful wins for bulk operations. The cost: when one operation inside a batch fails, tracing exactly which one and why is harder than debugging a single isolated request, since the response comes back as one bundled payload covering everything in the batch. Build in per-item error checking on the response rather than assuming an overall success means every individual operation succeeded.


When would you actually use this?
  • A bulk update or import needs to touch hundreds or thousands of list items -- batching is the difference between a script that finishes in seconds and one that gets throttled partway through.
  • You're migrating data into SharePoint and want to minimize the number of round-trips during the transfer.
  • A React component needs to update several related items on load or on a user action, without firing off a pile of uncoordinated individual requests.


That covers both syntax versions and the real limit behind them. Got a batching edge case? Drop it in the comments.


App Catalog Authentication Automation Backup Compliance Content Type CSS Flows Google Javascript Limitations List Metadata MFA Microsoft Node NodeJs O365 OneDrive Permissions PnP PnPJS Policy PowerApps Power Automate PowerAutomate PowerPlatform PowerShell React ReactJs Rest API Rest Endpoint Security Send an HTTP Request to SharePoint SharePoint SharePoint List SharePoint Modern SharePoint Online SPFX SPO Sync Tags Teams Termstore Versioning

Leave a Comment

Your email address will not be published. Required fields are marked *