If you want to use URL parameters in your notebook...
# show-and-tell
j
If you want to use URL parameters in your notebooks (to prefill inputs and create permalinks), here’s a library for you: https://observablehq.com/@jerryjappinen/url-params
👍 2
f
A pattern that I frequently use is
Copy code
params = Object.fromEntries(new URL(document.baseURI).searchParams)
and then e.g.
Copy code
viewof foo = Inputs.text({
  // ...
  value: params.foo ?? "some default"
})
j
Yup, that’s more or less what this does @Fabian Iwand. But a bit nicer to use across notebooks, and also parses numbers correctly
f
Fwiw when I need preset values other than strings I usually just JSON stringify/parse everything and store it in a single param