https://github.com/superioone/pnp-react-hooks
Pre-built React hooks for Pnp requests.
https://github.com/superioone/pnp-react-hooks
pnp react-hook sharepoint
Last synced: 6 months ago
JSON representation
Pre-built React hooks for Pnp requests.
- Host: GitHub
- URL: https://github.com/superioone/pnp-react-hooks
- Owner: SuperioOne
- License: mit
- Created: 2021-09-27T19:42:47.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2025-02-10T15:48:38.000Z (8 months ago)
- Last Synced: 2025-04-24T12:52:05.207Z (6 months ago)
- Topics: pnp, react-hook, sharepoint
- Language: JavaScript
- Homepage: https://prh.smdd.dev
- Size: 9.58 MB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PnP React Hooks
PnP React Hooks is a wrapper library for [PnPjs](https://pnp.github.io/pnpjs/),
provides configurable React hooks for SharePoint API to speed up
development for simple SPFx webparts and components.**Example usage:**
```jsx
import * as React from "react";
import { useListItems, useCurrentUser } from "pnp-react-hooks";export const ExampleComponent = () => {
const currentUser = useCurrentUser();const items = useListItems("My List", {
query: {
select: ["Title", "Id", "Author/Title"],
expand: ["Author"],
filter: `Author eq ${currentUser?.Id}`
},
disabled: !currentUser
});return (
- {item.Title} ))}
{items?.map(item => (
};
```
## Installation
```shell
npm install pnp-react-hooks @pnp/sp react
```
`@pnp/sp` and `react` packages are peer dependencies.
| Peer dependency | Supported versions |
|------------------|----------------------|
| `@pnp/sp` | 4.1.0 or later |
| `react` | 16.9.\* to 18.\*.\* |
## Features
- Build simple web parts quickly with less code.
- TypeScript support.
- Automatically tracks parameter changes and refreshes data as needed.
- Easy to tree-shake unused code with modern JS bundlers.
- Can be configured for multiple sites with an option provider.
- Supports [PnPjs behaviors](https://pnp.github.io/pnpjs/core/behaviors/).
## Documentation
For more details see the [docs site](https://prh.smdd.dev).
## Disclaimer
**PnP React Hooks library is an open source project under MIT license. It's NOT an official package distributed by Microsoft.**