For the last few weeks, I have been working with a client to build a SharePoint Framework web part. In that web part, we are required to retrieve SharePoint list items and allow users to update and delete the records.
As a SharePoint developer or SPFx developer, you should know how to do CRUD operations using React.
So, in this tutorial, I will explain how to perform CRUD operations using React in SPFx on SharePoint list items.
If you want to work with the No JavaScript framework, check out a tutorial on CRUD operations in SPFx using no JavaScript framework.
SharePoint List CRUD Operations using SPFx React
To do the CRUD operations using React JS in SPFx, we will use the following SharePoint Online list, which has a few columns, and the SharePoint list looks like the screenshot below.

This SharePoint list has the following fields:
| Column Name | DataType |
|---|---|
| Title [EmployeeName] | Default title field |
| JobDescription | Multiple lines of text |
| HireDate | Date and Time |
To interact with SharePoint list items for CRUD operations, we use the PnPJS library. In the example below, you can see that I built an SPFx web part that includes a form at the top that lets users add a new employee record.
In the table below, you can see all the employee records we previously added. The user can edit a record by clicking the Edit button, and to delete a particular record, click the Delete button.
Here is a screenshot for your reference.

Now, we’ll see the steps below to perform the CRUD operations mentioned above.
Note: Here, we will use PnP JS to save data into the SharePoint list from the web part.
- We’ll start by creating the SPFx solution. So open the command prompt and run the code below.
md SPFxCURDReact
cd SPFxCURDReact
This will create an empty directory. Now, we need to scaffold the SPFx project.
- Run the below command to quickly create a SharePoint client-side solution project with the right toolchain and project structure.
yo @microsoft/sharepoint
- What is your solution name? SPFxCURDReact
- Which type of client-side component to create? WebPart
- Add new Web part to solution sp-fx-crud-react.
- What is your Web part name? ListCURDReact
- Which template would you like to use? React

- To install the PnPJS library into our solution, run the command below.
npm install @pnp/sp --save
- Once it is installed successfully! Run the command below to open Visual Studio Code.
Code .
- Open the “ListCURDReactWebpart.ts” file and then provide the following PnP JS import statements.
import { spfi, SPFx } from "@pnp/sp";
import { SPFI } from "@pnp/sp";
import "@pnp/sp/webs";
import "@pnp/sp/lists";
import "@pnp/sp/items";
import "@pnp/sp/fields";
- In the same .ts file, add the below variable within the class.
private _sp: SPFI
We assigned the SPFI as a data type to this variable.
- Then, update your render() and onInit() methods as given below.
public render(): void {
const element: React.ReactElement<IListCrudReactProps> = React.createElement(
ListCrudReact,
{
description: this.properties.description,
isDarkTheme: this._isDarkTheme,
environmentMessage: this._environmentMessage,
hasTeamsContext: !!this.context.sdks.microsoftTeams,
userDisplayName: this.context.pageContext.user.displayName,
sp:this._sp,
context:this.context,
}
);
ReactDom.render(element, this.domElement);
}
protected onInit(): Promise<void> {
return this._getEnvironmentMessage().then(message => {
this._environmentMessage = message;
this._sp = spfi().using(SPFx(this.context));
});
}
In the onInit() method, we created a PnP Instance [this._sp] by passing the current context. Then, in the render() method, along with default props, we additionally added the following ones:
- sp:this._sp = Assigned PnP Instance to the prop sp.
- context:this.context = Assigned the current context to the prop context
- Now, we need to update the “Props.ts”file with the props we passed in the render() method in the previous step.
import { WebPartContext } from "@microsoft/sp-webpart-base";
import { SPFI } from "@pnp/sp";
export interface IListCrudReactProps {
description: string;
isDarkThem