JSFiddle - React, Tailwind, and code Playground

HTML

<script src="//cdnjs.cloudflare.com/ajax/libs/URI.js/1.11.2/URI.min.js"></script>
<span id="output">replaceme</span>

JavaScript

// N.B, this only works for show, breaks run.
if(('' + document.location).indexOf('?') < 0) {
    document.location += '?foo=bar&baz=bam';
} 
$('#output').text(new URI((''+document.location)).search(true).foo)