Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including spfxhelper with all npm packages installed. Try it out:

var spfxhelper = require("spfxhelper")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

spfxhelper v4.0.1

Bundle of core functions which can be used in every project

SharePoint Framework Helper

SharePoint Framework Helper

In the need to develop the solution faster and easier I have created a npm package, which will give you the flexibility to enjoy the much used logic handy and easy when writing code for SharePoint framework client side webparts or SharePoint framework extensions.

This npm package contains the most commonly used functions or I should say the operations that are used almost in every SPFx client side webpart or SPFx extensions. Using this npm package you can create your webparts much more easily and faster. This is very simple and handy.

This npm package code is also available on GitHub so if you are interested you can have a look at the implementation as well, or even you can request for the addition of new methods that you feel might help others as well.

Why to use ?

  • This library contains handy functions that will save lot of man hours in implementing
  • Well designed results so it will help in writing the code efficiently
  • Well broken into the type of operation, so include only the class that is most useful to you

How to use ?

To install the package execute the below command

> npm i spfxhelper

And then import the following in the code file

import { "CLASS_NAME" } from 'spfxhelper';

Inside the library

  • This library contains a number of classes


This class contains all the methods that are responsible for the interaction of the SharePoint List.

createFolderInDocLibcreates the folder in document library
createFolderInListcreates the folder in list
createListcreates the list
createListItemcreates the list item
getContentTypesByListReturns the content types associated with the list
getInstancereturns the instance of the class
getListBytitlereturns the list details by title
getListItemByIDget the list items based on the item ID
getListItemsreturns all the list items based on the row count. If row count is not provided will return max i.e.. 100
getListItemsByQueryget the list items based on the query parameter
getListMetadatareturns the list metadata required to create the list
getListsDetailsByBaseTemplateIDReturns the lists based on the template ID
getViewsByListReturns the lists views
updateListItemupdates the list item


This is the class responsible for the operations related to SharePoint Fields.

addColumnToListadd the column to the list
addFieldToViewadds the field to the view in the list
addSiteColumnToListadds the site column to the list
createListColumncreates the list column
createSiteColumncreates the site column
getColumnMetadatareturns the column metadata required for the creation of the column
getFieldByListreturns the field details from the list
getFieldBySitereturns the fields details of the site column
getFieldByViewreturns the field details by view
getFieldsByListreturns all the fields associated with the list
getFieldsByViewreturns all the fields associated with view in a list


This class is the extension of the base class where one can query the API's which are not available as methods in other classes

getDocIconByFilesreturns the OOB icons for the file types
getInstancereturns the instance of the class
queryGETResquestmethod to query any custom query with 'GET' verb
queryMERGERequestmethod to query any custom query with 'MERGE' verb
queryPATCHRequestmethod to query any custom query with 'PATCH' verb
queryPOSTRequestmethod to query any custom query with 'POST' verb

SPCore (renamed from SPHelperCommon)

This class contains only static methods and contains the helper methods

calculateAgereturns the age from the specified date
getFieldInternalNamereturns the internal name of the field (removes the x0020)
getLocalStoragereturns the local storage object
getParameterValuereturns the parameter value from URL
isEmptyStringchecks for the string emptiness
isNullcheck for the object null


This class has been removed from the library. Instead use the OOB class Log in sp-core-library.

import { Log } from '@microsoft/sp-core-library';

Use the following methods

static error(source: string, error: Error, scope?: ServiceScope): void;
static info(source: string, message: string, scope?: ServiceScope): void;
static verbose(source: string, message: string, scope?: ServiceScope): void;
static warn(source: string, message: string, scope?: ServiceScope): void;

Do share how I can improve this library, so it can help all the SharePoint community

Happy Coding

#SharePointWidgets #MicrosoftSharePoint

Sumit Kanchan

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free