Build SharePoint Framework client side web part – I

Suggested Articles

What is SharePoint Framework (SPFx)

Future prospects of SharePoint Framework (SPFx)

Required tools and libraries for SharePoint Framework (SPFx) development

Setup Office 365 tenant for SharePoint Framework development

Setup SharePoint Framework client side web part development environment


This article describes how we can create a new SharePoint Framework client side web part. We’ll also use various tools to build the web part. Let’s begin with creating a new web part project.



Create new web part project

You need to perform following steps:

  1. Create new project directory at your opted location

md helloworld-webpart

  1. Go to project directory

cd helloworld-webpart

  1. Create project using Yeoman SharePoint Generator

yo @microsoft/sharepoint

It will ask for few inputs, provide the inputs as follows:

  1. Solution name? helloworld-webpart
  2. Type of client-side component to create? WebPart
  3. What is the web part name? HelloWorld
  4. What is your web part description? This is my first client side web part using SharePoint Framework
  5. Which framework would you like to use? No JavaScript Framework




At this point, Yeoman will install dependencies and generate files for HelloWorld web part. Once processing is completed, it will show success message.




Using Code Editor

This solution is build using HTML/Typescript. You can use any editor that support client side development.

I am using Visual Studio Code from Microsoft. It is a lightweight but powerful source code editor which runs on desktop of Windows, Mac and Linux. Visual Studio Code supports JavaScript, Typescript and Node.js. It has many extensions for other languages like C++, C#, PHP and Python and runtimes.


Preview web part

Run the following command to establish trust

gulp trust-dev-cert




You will see a security warning as below, click Yes to install.




Now you have installed developer certificate. Run following command to build and preview your web part.

gulp serve


You may be asked for warning. Click Allow access.




SharePoint client side development tool gulp is a task runner which performs build processes tasks such as:

  1. Bundle and Minify JavaScript and CSS
  2. Run tools to call bundling and minifying tasks before each build
  3. Compile CASS to CSS
  4. Compile Typescript to JavaScript

Visual Studio Code provides built-in support for gulp and other task runners. Choose Ctrl+Shift+B on Windows or Ctrl+Shift+B on Mac to debug and preview your web part.



Now, It will launch SharePoint Workbench where you can add your client side web part on the page. This is helpful while development as you don’t need to deploy your client side web part every time while it is under development.




You can stop gulp by choosing Ctrl+C in command prompt where gulp is running. Then you will provide answer Y to stop it.


To Be Continued…



About Satyendra Mishra

An Engineer by education, Satyendra is a PMP certified Project Manager, Author, Blogger and Learner with 13+ years of experience on Project Management, Microsoft Technologies including ASP.NET, ASP.NET MVC, C#, SharePoint (On premises & Office 365), JavaScript Framework (Angular), Xamarin for Android and related technologies. He is a person with belief, sky is limit for a hard working and dedicated individual. That’s why he devoted himself to field of Software Development and now both are growing with each other. Every year for him turned out to be best year and he received enormous support and love from his companies and his clients from around the world. Now with vast knowledge of software development and its outsourcing process, he decided to move himself into knowledge sharing. Keep a fact in your mind about the comfort level of your clients and this will make you king/queen of your area.
View all posts by Satyendra Mishra →