How to create new VIEW in SharePoint List using PnP JavaScript Library.

Syntax:

pnp.sp.web.lists.getByTitle(<ListName>).views.(
title: string,
personalView = false,
additionalSettings: TypedHash<string | number | boolean> = {}): Promise<ViewAddResult>
Adds a new view to the SharePoint List based on the specified parameters
ListName - Title of the SharePoint List, where we want to add the view
@param1 > title - The new views's title
@param2 > personalView - True if this is a personal view, otherwise false, default = false
@param3 > additionalSettings - Will be passed as part of the view creation body

Example:

The below steps and code snippets used to create a new view in SharePoint list using PnP JavaScript library,

Download Required files to use PnP-JS-Core library from the below links and upload that to Site Asstes or Style Library

Typescript Example:

Typescript is the superset of JavaScript and this PnP JS library is developed using the typescript specification. For developing the SharePoint Framework web parts and make the client side development easier, we can vote for typescript. The below is the typescript example for adding a new view to the SharePoint List.