top of page
  • Writer's pictureAndyH

Reading the querystring


Examining the querystring up close

My web part needed to read a querystring. SharePoint Framework has a tool for that!


When I have created little chunks of JavaScript in the past and wanted to read the querystring, I needed to write my own code to get to the various parts easily. Fortunately there is a way to do this thanks to a useful blog post by Paul Matthews:

var querystring = new UrlQueryParameterCollection( window.location.href ); var id = querystring.getValue( "myId" );

This handy class lives in the Microsoft SP Core library, remember to add an import for it in your script:

import { UrlQueryParameterCollection } from '@microsoft/sp-core-library';
69 views0 comments

Recent Posts

See All
bottom of page