Sunday, June 9, 2019

How to get URL parameters in Lightning Web Components??

Hello Guys, hope you are doing great!

Did you have a requirement to get the URL parameters in Lightning web component and use them further??

Here is the simple answer. As LWC is purely based on Javascript, we can utilize the Javascript functions to do this activity. I was working with communities and wanted to pass on some URL parameters, here is the implementation.

This was my URL.

<Community URL>?eventid=00UJ000000AzjeuMAB



    var eventId = ((new URL(window.location.href)).searchParams.get("eventid"));

The above line will give me the Event Id retrieved from URL. Sooo simple.

I hope you liked the post and it helped. Let me know your suggestions and feedback. 

Thank you so much for visiting.

No comments:

Post a Comment

Salesforce: Export to Excel with Lightning Web Component

Hello Guys, I hope you are doing well. In this post, we are going to see an implementation of " Export to Excel" in lightn...