- SPFx SPO List CRUD Web Parts
This project contains SharePoint Framework (SPFx) web parts that demonstrate CRUD (Create, Read, Update, Delete) operations on SharePoint Online lists. The web parts are built using React and leverage the SharePoint REST API to interact with list data. These examples showcase how to perform basic data manipulation tasks within a SharePoint Online environment, providing a practical reference for developers looking to implement similar functionality in their own SPFx solutions.
This solution contains two webparts
- PnPJS SP CRUD
- PnPJS React CRUD
This SPFx webpart(s) solution illustrates the following concepts:
- How to use getsp and getgraph modules to centrally create _sp and _graph objects using common context
- How to perform CRUD operations using pnpjs sp api on sample SP List
- How to read user details using pnpjs graph api.
- How to configure PnPJS logging.
Notice that better pictures and documentation will increase the sample usage and the value you are providing for others. Thanks for your submissions advance.
Share your web part with others through Microsoft 365 Patterns and Practices program to get visibility and exposure. More details on the community, open-source projects and other activities from http://aka.ms/m365pnp.
[!WARNING] Important Every SPFx version is only compatible with specific version(s) of Node.js. In order to be able to build this sample, please ensure that the version of Node on your workstation matches one of the versions listed in this section. This sample will not work on a different version of Node.| |Refer to https://aka.ms/spfx-matrix for more information on SPFx compatibility. |
For more information about SPFx compatibility, please refer to https://aka.ms/spfx-matrix
Get your own free development tenant by subscribing to Microsoft 365 developer program
Chirag Patel
| Version | Date | Comments |
|---|---|---|
| 1.0.2 | March 30, 2025 | Initial Release |
Important
react@17.0.1 react-dom@17.0.1 are required version for SPFx 1.21.1 compatibility
npm i react@17.0.1 react-dom@17.0.1 --save-exactOther dependencies to validate if npm install does not resolve
npm install @microsoft/applicationinsights-web --save
npm install office-ui-fabric-react --save
npm install simple-react-validator --save
npm install @pnp/sp --saveInclude any additional steps as needed.
[!WARNING]Debug solution locally
gulp clean gulp build gulp serve --nobrowserhttps://m365devlab01.sharepoint.com/sites/M365AppDev/_layouts/workbench.aspx
Permissions are defined in package-solution.json file to grant graph api access level.
"webApiPermissionRequests": [
{
"resource": "Microsoft Graph",
"scope": "User.Read.All"
}
] "webApiPermissionRequests": [
{
"resource": "Microsoft Graph",
"scope": "Directory.Read.All"
},
{
"resource": "Microsoft Graph",
"scope": "User.Read"
},
{
"resource": "Microsoft Graph",
"scope": "User.Read.All"
},
{
"resource": "Microsoft Graph",
"scope": "Group.Read.All"
}
]"isDomainIsolated": true,
"webApiPermissionRequests": [
{
"resource": "Microsoft Graph",
"scope": "Directory.Read.All"
},
{
"resource": "Microsoft Graph",
"scope": "User.Read"
}
] π .vscode/
βββ π οΈ settings.json - Configuration settings for Visual Studio Code.
βββ π οΈ launch.json - Configuration for launching and debugging the application.
π config/
βββ π οΈ config.json - Configuration file for the project.
βββ π copy-assets.json - Configuration for copying assets.
βββ π οΈ deploy-azure-storage.json - Configuration for deploying to Azure Storage.
βββ π serve.json - Configuration for serving the project locally.
βββ π¦ package-solution.json - Configuration for packaging the solution.
π lib/
βββ π index.js - Compiled JavaScript files.
π node_modules/ - Directory containing project dependencies.
βββ π @pnp/
β βββ π sp/ - SharePoint PnP JS library.
β βββ π graph/ - Microsoft Graph PnP JS library.
β βββ π logging/ - PnP logging library.
βββ π react/ - React library version 17.0.1.
βββ π react-dom/ - React DOM library version 17.0.1.
βββ π [Other npm packages]
π src/
βββ π webparts/
β βββ π pnPspCrud/
β β βββ π PnPspCrudWebPart.module.scss - Styling for the PnP SharePoint CRUD web part.
β β βββ π PnPspCrudWebPart.ts - Entry file for the PnP SharePoint CRUD web part.
β β βββ π PnPspCrudWebPart.manifest.json - Manifest file for the PnP SharePoint CRUD web part.
β βββ π pnpJsReactCrud/
β β βββ π components/
β β β βββ π IPnpJsReactCrudProps.ts - Interface for the properties of the PnP JS React CRUD component.
β β β βββ βοΈ PnpJsReactCrud.tsx - Main React component for the PnP JS CRUD operations.
β β β βββ π PnpJsReactCrud.module.scss - Styling for the PnP JS CRUD component.
β β βββ π PnpJsReactCrudWebPart.ts - Entry file for the PnP JS CRUD web part.
β β βββ π PnpJsReactCrudWebPart.manifest.json - Manifest file for the PnP JS CRUD web part.
β βββ π Repository/
β β βββ π ISharePointBaseRepository.ts - SharePoint Base Repository interface file.
β β βββ π SharePointBaseRepository.ts - SharePoint Base Repository concrete class file.
βββ π index.ts - Main entry point for the project.
βββ π webparts.ts - Entry point for all web parts.
π .gitignore - Specifies files and directories to be ignored by Git.
π .npmignore - Specifies files and directories to be ignored by npm during package installation.
β‘ gulpfile.js - Gulp tasks for build automation.
π¦ package.json - Project metadata and dependencies.
π README.md - Project documentation.
π― .yo-rc.json - Yeoman configuration file.
βοΈ tsconfig.json - TypeScript compiler configuration file that specifies root files and compiler options required to compile the project.
Tenant App Catalog
https://
<tenant>.sharepoint.com/sites/appcatalog/_layouts/15/tenantAppCatalog.aspx/manageAppsClientSide Assets library:
https://
<tenant>.sharepoint.com/sites/<site name>/ClientSideAssetsComponent Manifests
https://
<tenant>.sharepoint.com/sites/<site name>/ComponentManifests
From
- Getting started with SharePoint Framework
- Building for Microsoft teams
- Use Microsoft Graph in your solution
- Publish SharePoint Framework applications to the Marketplace
- Microsoft 365 Patterns and Practices - Guidance, tooling, samples and open-source controls for your Microsoft 365 development
THIS CODE IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.