Sivarajan's Blog

SharePoint | Office 365 | Azure | JavaScript

SharePoint Framework Client WebPart–Playing with context, pageContext, Web, User and CultureInfo


As a SharePoint developer, we are familiar with SPContext. We can easily access the current Site, Web and User related information from SPContext.Current. In this post, we will see that how to get the similar details from SharePoint Framework Client WebPart.

Create a new WebPart

The prerequisites of SharePoint Framework Client Side development is that,

  • NodeJs
  • Visual Studio Code

I have explained in my previous posts on how to install and configure NodeJs and VS Code. In addition to that, here you find more details about creating a Hello World WebPart.

this.Context (IWebPartContext)

This is a similar to SPContext. One of the important properties is pageContext and we can access the following properties from that,

  • Site
  • Web
  • User
  • CultureInfo


This will return the Absolute URL, Relative URL, Web site title and Web site unique ID. Here is the syntax for that.


The output of the above code is,



This will return the logged in user’ loginName and displayName.


The output of the above code is,



This will return the site culture information. Based on that, we can localize the webpart easily.


The output of the above code is,



In the post, we will see that few important SharePoint Framework properties. In the next post, we will see that, how to use httpClient object.

Add comment