-
Notifications
You must be signed in to change notification settings - Fork 0
Live URL Parameters
Brandon Jordan edited this page Sep 11, 2024
·
3 revisions
Spark provides a class for the handling and updating of URL parameters in real time.
https://example.com/page?id=1
const urlParams = new LiveURLParams();
if(urlParams.has('id')) {
idVariable = urlParams.get('id'); // 1
urlParams.delete('id');
}
When id
is deleted, it is not only deleted from the URL params object but from the URL as well, as when any updates are made, a new history state is pushed.
https://example.com/page
The same is true for setting a param.
urlParams.set('status', newStatus);
https://example.com/page?status=pending