It would be really cool if we could load notebooks with hash params #key=value&secret=123 and have them loaded into the notebook in some way. This would allow doing things like passing in access_tokens for apis without compromising the sharability of the notebook (and in fact improving it).
You already can do something like that
Take a look at this notebook
You can already store secrets in Observable that only you can access:
Itās not exactly the same. The key difference is that a hash wonāt get send to the server and can thus not be logged server-side. Obtaining the hash is currently not possible:
Yes, I was referring to query string option (though I did not remember, that hash option was not working )
Access to hash params would also allow for much longer parameters to be passed to a notebook. Iāve been messing around with a code editor in an Observable notebook and it would be nice to be able to share permalinks to code examples using hash params. Query strings have a max length which is inconvenient for this use case.
Yeah its great that you can use query strings (I though that was restricted too actually), but hash params would open up some new possibilities for the reasons mentioned (they donāt get sent automatically by the browser and increased size limits).
Where/when did you encounter this limit? Afaik it should be high enough that youāll rarely hit it.
For massive amounts of data thereās also the option to gzip the data and encode it with a base higher than 64. Perhaps thereās also a way to get deflate to output a limited character range, but I havenāt found anything conclusive yet.
Youāre probably right; with some more testing, the limit for observablehq.com seems to be ~5k characters and passing around URLs of that length is problematic no matter how the data is encoded. Hereās something close to what Iāve been working with:
I think I was remembering what happened with some other server which had a much lower limit. Nonetheless, I support the request for access to hash params.
I have a UrlParam
class in one of my notebooks that encodes and decodes arbitrary data:
The notebook also contains a more complex example of retrieving and applying data for multiple cells. Applying URL data happens in the second cell (which has no output unless thereās data).
Applied to your notebook it would work like this (note that you donāt need to share the UrlParam instance, you can create as many as you like whenever you like):
Btw, I found that Observableās server stops responding to URLs somewhere between 7000 and 8000 characters.
Wow thanks, this is really great! Iāve merged your suggestion.
Great discussion as always, folks.
Weāve just pushed a change that copies querystrings and hash parameters down from the notebookās parent frame to the worker, so you can now use location.search
(for querystrings) and location.hash
(for client-side hash parts) much more naturally.
Hereās a little demo:
Woo you guys are awesome!!
@jflatow If you click the button under Jeremyās answer, itāll mark this topic as resolved and make it so that future visitors will see the solution right away.