Get Current User Properties Using PNP Js

SharePoint MVP
August 29, 2019
Rate this article
[Total: 0    Average: 0/5]

In this article. I have explained how to get current user properties of the SharePoint user using pnp js.

Introduction To PNP Js

PNP means Patterns and Practices is a JavaScript library to accomplish SharePoint operations in more productive way for both SharePoint online and on-premise versions

In previous REST API Calls we fetch the current user properties using the below endpoint through AJAX


Method: GET

Now let see how to done the same using PNP JS in the simplest way.

Import the PNP library from node

import pnp from "@pnp/pnpjs";

pnp.sp.web.currentUser.get().then(f => {
console.log("user", f);

It will return the successful response like below in JSON format

you can also use same JavaScript library of PNP Js in your normal JavaScript projects like Content editor webparts like below snippet

console.log("user", response);

Download it form CDN.

In my upcoming blogs let discuss more operations using PNP JS

Happy SharePointing !…

Category : Office 365, OnPremise, PNP

Author Info

SharePoint MVP
Rate this article
[Total: 0    Average: 0/5]
Vinodh is a Microsoft MVP for SharePoint (Office Apps and Services) having 5+ years of experience in Microsoft Technologies. His interest and expertise includes SharePoint Online Development, PowerApps Development, Flows more

Leave a comment