spacer
Skip to content

@pnp/sp/publishing-sitepageservice

Selective Imports Banner

Through the REST api you are able to call a SP.Publishing.SitePageService method GetCurrentUserMemberships. This method allows you to fetch identifiers of unified groups to which current user belongs. It's an alternative for using graph.me.transitiveMemberOf() method from graph package. Note, method only works with the context of a logged in user, and not with app-only permissions.

Get current user's group memberships

import { spfi } from "@pnp/sp";
import "@pnp/sp/publishing-sitepageservice";

const sp = spfi(...);

const groupIdentifiers = await sp.publishingSitePageService.getCurrentUserMemberships();