Wednesday, August 7, 2019

How to get URL parameters in Lighting web componet(lwc)

This post explains how to read URL parameters in Lighting Web Components(lwc)

In this demo, I am using static URL if you want to get URL dynamically
Use window.location.href

Example URL:
// if you have Dynamic URL Use (window.location.href)
let testURL = '';

let newURL = new URL(testURL).searchParams;

console.log('id ===> '+newURL.get('id'));
console.log('image ====> '+newURL.get('image'));

1 comment: