Skip to main content

shinyhub-bookmarks

Selective URL bookmarks for Python Shiny apps running in ShinyHub.

The package registers the filters an app author considers meaningful. ShinyHub then adds a Bookmark this view control to its app switcher. Visitors see a plain-language receipt, can copy the exact view immediately, or customise which registered filters follow the link. Unselected filters return to the app's defaults when the bookmark opens.

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"),
            "year": Field("Year"),
        },
    )

    @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.

Bookmarks 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,
    schema_version=3,
    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. A missing declared default falls back to the valid value Shiny already selected.

renamed_from maps an old input ID to its former label. legacy_fields names removed inputs that should be reported as ignored. Every new link records the app's schema_version; older links without metadata remain supported.

When anything changes, the switcher marks the bookmark action and presents a plain-language View adjusted receipt. It names migrated, unavailable, renamed, and removed filters and offers Copy updated link. 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 Unknown. 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. The ShinyHub server neither receives nor persists bookmark state; selected values stay in Shiny's URL.
  • Every registered field is selected by default, including values equal to the app's current defaults. The receipt makes that scope explicit before copying.
  • App inputs not registered here are always excluded.
  • A custom bookmark with no selected fields cannot be created.
  • URLs over 8 KiB are rejected by default. Raise max_url_length only 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

shinyhub_bookmarks-0.2.0.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shinyhub_bookmarks-0.2.0-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file shinyhub_bookmarks-0.2.0.tar.gz.

File metadata

  • Download URL: shinyhub_bookmarks-0.2.0.tar.gz
  • Upload date:
  • Size: 14.6 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

Hashes for shinyhub_bookmarks-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ef7283f24f00c4eea49e04a43728ea4742e85c5eb3d3e507303ecc095a049f16
MD5 0b1836c48c76336b9ebedf3c3c1b2847
BLAKE2b-256 8522898320877059fe43260002cd1ae2af3bc24208c6f7e07e08163cfd935945

See more details on using hashes here.

Provenance

The following attestation bundles were made for shinyhub_bookmarks-0.2.0.tar.gz:

Publisher: publish-bookmarks.yml on rvben/shinyhub

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file shinyhub_bookmarks-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: shinyhub_bookmarks-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 12.0 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

Hashes for shinyhub_bookmarks-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b337faf2e61d759273116ebdb90daf5f15eff88c63f437c1aa07bc94e57d58a9
MD5 5d7fea253a9d702528d5bf52f1043caa
BLAKE2b-256 34c30a1c3995f66eb3457eeae74bdaa3c544e0cf5bca669c2910a41eb210385e

See more details on using hashes here.

Provenance

The following attestation bundles were made for shinyhub_bookmarks-0.2.0-py3-none-any.whl:

Publisher: publish-bookmarks.yml on rvben/shinyhub

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.5.1

2 files

0.5.0

2 files

0.4.0

2 files

0.3.0

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

This release

0.2.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page