shinyhub-bookmarks
Selective view links for Python Shiny apps running in ShinyHub, built on Shiny's URL-bookmarking API.
The package registers the filters an app author considers meaningful. ShinyHub then adds a Link to this view control to its app switcher. Visitors can copy the exact view immediately or use Change to choose which registered values follow the link. Unselected values return to the app's defaults when the link opens. The visible UI says “link”; package and API names retain “bookmark” to match Shiny's native lifecycle.
uv add shinyhub-bookmarks
# or: python -m pip install shinyhub-bookmarks
from shiny import App, render, ui
from shinyhub_bookmarks import ChoiceRestore, Field, bookmarking_dependency, register
def app_ui(request):
return ui.page_fluid(
bookmarking_dependency(),
ui.input_select("region", "Region", ["Europe", "Americas", "Asia"]),
ui.input_slider("year", "Year", 2020, 2026, 2026),
ui.output_text_verbatim("summary"),
)
def server(input, output, session):
register(
session=session,
input=input,
fields={
"region": Field("Region", baseline="Europe"),
"year": Field("Year", baseline=2026),
},
)
@render.text
def summary():
return f"{input.region()} · {input.year()}"
app = App(app_ui, server, bookmark_store="url")
Both pieces are required: bookmarking_dependency() installs the tiny browser
bridge, and register() publishes the allow-list and creates links through
Shiny's native bookmarking API. The UI must be a function accepting request
so Shiny can restore URL state before rendering it. Call register() exactly
once from the top-level server session. Module inputs can be included by their
resolved IDs in that top-level field mapping; module-scoped registration is
rejected because selective exclusion is owned by the root bookmark session.
After a registered filter changes, the bridge also updates the current address after a short debounce. The live address contains only values that differ from their baselines. It replaces the current browser-history entry, so a refresh or ordinary browser bookmark reopens the same view without filling the Back button with every intermediate slider or text-input value. The explicit Link to this view action remains the exact, selective sharing control.
Declare stable baselines with Field(baseline=...). This is comparison
metadata; it does not set the Shiny control's initial value. On a clean page,
the helper logs a mismatch without logging either value and safely retains the
current value until it reaches the declaration. Without a declaration, it
learns the first materialized value—even for a dynamically rendered input.
Declare baseline= when later initialization code changes that first value.
Baseline comparison is semantic. Meaningful falsy values such as False, 0,
and an empty selection remain in the URL when they differ from the baseline.
ChoiceRestore.default has a separate job: it is only the fallback for an
unavailable saved choice. A field restored before its baseline is known remains
in later live URLs for refresh safety.
The live URL is minimal; the explicit Copy link action is exact and includes every checked field, even one at baseline. An opened exact link stays full until a registered value changes, after which live synchronization minimizes it.
View links that outlive the app
Native Shiny restoration ignores a removed input, but a retired choice can otherwise become empty or fall back differently across widgets. Declare current choices when a bookmark should remain dependable across app releases:
register(
session=session,
input=input,
legacy_fields={"segment": "Market segment"},
fields={
"region": Field(
"Region",
restore=ChoiceRestore(choices=REGIONS, default="Europe"),
renamed_from={"territory": "Territory"},
),
"product": Field(
"Product",
restore=ChoiceRestore(
choices=lambda: PRODUCTS,
default="All products",
aliases={"Legacy planning": "Planning"},
control="select",
),
),
},
)
ChoiceRestore validates the saved value, applies aliases, and updates the
current Shiny choice input. Supported controls are select, selectize, and
radio. Multiple selections retain every choice that still exists, use the
current display order, and preserve an empty selection. A missing declared
default falls back to the valid value Shiny already selected. Dynamically
rendered choice inputs are validated once they materialize.
renamed_from maps an old input ID to its former label and requires a
ChoiceRestore policy so the saved value can actually be applied to the new
control. legacy_fields names removed inputs that should be reported as
ignored. The helper adds no package-specific schema or version metadata to the
URL. Shiny may still include application-owned bookmark values when an app
adds them through its own callbacks.
For a custom input whose live Python value differs from its JSON bookmark
representation, pass an idempotent normalizer= to Field. It is applied to
both sides before comparison; it does not change the value Shiny serializes or
restores.
When anything changes, the switcher marks the link action and presents a plain-language Opened with changes receipt. It labels saved and opened values for migrated, unavailable, renamed, and removed fields, then offers Copy link to current view. The app still opens; stale state is never promoted into a blocking error.
An input that is neither registered nor declared as renamed or removed is shown with its URL-provided ID and saved value, labelled Not recognized. Both are rendered as bounded plain text. At most three unknown inputs are listed before a compact overflow summary. Copying the updated link drops every unknown setting, so the warning clears on the next visit.
Privacy and behaviour
- The browser-local ShinyHub switcher receives the registered display values and generated URL so it can show the receipt and copy the link. ShinyHub has no dedicated bookmark-state API or store. The URL query still follows the browser, proxy, and Shiny request path and may appear in browser history, deployment logs, analytics, or referrer data.
- Every registered field is selected by default, including values equal to the app's current defaults. The receipt makes that scope explicit before copying.
- Helper-created links exclude unregistered Shiny inputs. App-owned bookmark
callbacks may still add
state.values, which Shiny preserves as_values_. - A view link with no selected fields cannot be created.
- URLs over 8 KiB are rejected by default. Raise
max_url_lengthonly when the complete delivery path is known to accept longer URLs. - The control stays absent when the bridge is not installed, so unsupported apps never show a dead action.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file shinyhub_bookmarks-0.5.0.tar.gz.
File metadata
- Download URL: shinyhub_bookmarks-0.5.0.tar.gz
- Upload date:
- Size: 25.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b10bcac6fead7f26aa6fbd86b54941ced8c41a389b616649934fd47f603e96a8
|
|
| MD5 |
f4d25d9b15699906396afa65fe81d6a3
|
|
| BLAKE2b-256 |
de7f7b24c53eb38969f3a03fe80a49f6cc1c92eb56989f6287b82085566baa49
|
Provenance
The following attestation bundles were made for shinyhub_bookmarks-0.5.0.tar.gz:
Publisher:
publish-bookmarks.yml on rvben/shinyhub
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
shinyhub_bookmarks-0.5.0.tar.gz -
Subject digest:
b10bcac6fead7f26aa6fbd86b54941ced8c41a389b616649934fd47f603e96a8 - Sigstore transparency entry: 2685259788
- Sigstore integration time:
-
Permalink:
rvben/shinyhub@d58f1df658753151569502ab7bd93d106ab8fac6 -
Branch / Tag:
refs/tags/shinyhub-bookmarks-v0.5.0 - Owner: https://github.com/rvben
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-bookmarks.yml@d58f1df658753151569502ab7bd93d106ab8fac6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file shinyhub_bookmarks-0.5.0-py3-none-any.whl.
File metadata
- Download URL: shinyhub_bookmarks-0.5.0-py3-none-any.whl
- Upload date:
- Size: 18.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f899f42393477e957ee2a0815287740bc3a808c5e9e863f9b6e4a7dc68f029a
|
|
| MD5 |
c4d926f539d873cff5122d3cd03f2e9c
|
|
| BLAKE2b-256 |
bb2882ec398cd3bcaeac3b111ebed5bbb7eba7f54aaa1f3cb13e36055f6d56ab
|
Provenance
The following attestation bundles were made for shinyhub_bookmarks-0.5.0-py3-none-any.whl:
Publisher:
publish-bookmarks.yml on rvben/shinyhub
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
shinyhub_bookmarks-0.5.0-py3-none-any.whl -
Subject digest:
9f899f42393477e957ee2a0815287740bc3a808c5e9e863f9b6e4a7dc68f029a - Sigstore transparency entry: 2685259727
- Sigstore integration time:
-
Permalink:
rvben/shinyhub@d58f1df658753151569502ab7bd93d106ab8fac6 -
Branch / Tag:
refs/tags/shinyhub-bookmarks-v0.5.0 - Owner: https://github.com/rvben
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-bookmarks.yml@d58f1df658753151569502ab7bd93d106ab8fac6 -
Trigger Event:
push
-
Statement type: