Friday 1 September 2017

Basics of SPFX

SPFX is the new way or you can say a new development model in SharePoint based on open source technologies like nodejs , Gulp , Yeoman , webpack , reactjs , angularjs typescript etc.
SPFX is a development model that provides full support for client side development and deployment.

Normally, SharePoint developers work on  SharePoint Solutions that are based on features/solutions / javascript JSOM using Script Editor / content editor webpart or Apps (now addin). and so it is hard for them to learn and work on above mentioned open source technologies.

Since SPFX is based on client side development so it is going to be very popular in fact it is already. so every SharePoint developer should now start learning these technologies as these are going to be future of SharePoint.
We can use SPFX to develop powerful client side solutions for office 365 and Feature pack 2 of on-premise SharePoint 2016.

lets see some problems with old client side development ways and some problems with that

Script Editor

Script Editor is probably one of the most popular web part in SharePoint which developer uses to inject scripts in pages but the problems are.
  1.  It is not marked as safe for scripting.
  2. There are certain cases where NOSCRIPT feature is enables on most of self service sites. simply it can not be used there.
  3. You can not provide configuration options easily.

Addin Model

Addin model provides app parts which can be used in No Scripts scenarios but the biggest downside of  this App Part is that it loads in IFrame and caused several issue. if you solve them then it will take much time to load.

Key Features of SPFX Model

Now lets see what are some of the key features of SPFX.

  1. You should be using some javascript framework for development and of course you need to know at least one of them like Angular , Knockout , React etc.
  2. You can access the life cycle of controls like render , load , serialise , deserialise etc.
  3. Controls are responsive in nature , the solution runs in browser with current user credentials
  4.  Solutions are based on tools like TypeScript , gulp, yeoman etc
  5. End users can add/use the solutions developed by developer once it is approved by tenant admins. 
  6. Solutions developed can be used on both modern and classic pages.
  7. There is something called workbench which can be used to test the web parts etc locally before they actually deployed to SharePoint

What a developer should know to get started with SPFX

  1.  First you should create office 365 tenant or join office developer program if you already have then create a developer site collection and app catalog site.
  2. TypeScript : if you know C# then it will be easy to learn. it is a super set of javascript that provides strong typing in javascript like classes , interfaces , modules and much more.
  3. Nodejs : you should have some basic understanding of node js and npm (node package manager)
  4. JavaScript Framework : you should know at least one javascript framework like React , Angular 1.x , Angular 2 with TypeScript 2.x .  to learn react you can have a look on ReactJS Tutorial
  5. Yeoman : Yeoman provide generators or project templates. its like similar as visual studio uses project templates.  so you should have some basic understanding on Yeoman and basically you will be using some npm commands to generate your SPFX project templates.
  6. Gulp : gulp provides build process task runner. you should have some basic understanding of gulp and you will learn more as you progress with SPFX.  it does alot of task for you like building and minifing css files and much more.
  7. WebPack : Webpack is used to create bundle for webpart files and dependencies.   
For a SharePoint developer, initially it is relatively complicated to learn these but you should have a basic understanding of these to get started with code samples on Microsoft Pantterns and Practices
and slowly you will learn a lot of things.



Capabilities of SPFX

What you know about spfx will never be of use until you do not know what SPFX can do.
It is realy hard to write what SPFX can not do. but what it already does can be written down here.
Community is working to add more capability so you should always look on Microsoft Patterns and Practices
Lets have a look on what kind of stuff we can develop for now with SPFX.
  1. Client Side Web Parts :  you can write client side web parts that can be added on a page . two webparts can have connection with each other.
  2. Field Customizers :  it is like JS Link . It is a javascript object that can change the rendering of a field in a list or library .  with field customizers you can change the rendering of a cell based on the data in cell.
  3. Application Customizers  : with Application customizers you can add some object on each page of SharePoint. this also comes with a contract from microsoft with specific named div elements on the page. Application customizer allows us to create custom header and footer or add some google analitics or any thing there. it is like delegate controls it not that?.
  4.   Command Sets : if you want to add some button in ECB menus (context menu of list or library) or toolbars of lists or libraries then you should be writing command sets. its like custom actions, it not that ?

Whats Next

You can have a look on how to setup dev environment for spfx

https://sppractices.blogspot.in/2017/09/setup-dev-environment-for-spfx.html

To know what are the new things coming with SPFX you should always have a look on the Microsoft Patterns and Practices.

https://dev.office.com/patterns-and-practices





1 comment:

  1. Nice Article, Thank you so much giving your time for this wonderful articcle. Keep it up sharepoint development

    ReplyDelete

Setup dev environment for spfx

So lets setup dev environment for SharePoint Framework abbreviated as SPFX. for an Introduction of What is SPFX and What are the capebiliti...