Skip to content

Docs for URL pages and navigation#14480

Merged
lukasmasuch merged 3 commits intostreamlit:developfrom
MathCatsAnd:docs-external-streamlit-pages
Mar 24, 2026
Merged

Docs for URL pages and navigation#14480
lukasmasuch merged 3 commits intostreamlit:developfrom
MathCatsAnd:docs-external-streamlit-pages

Conversation

@MathCatsAnd
Copy link
Copy Markdown
Contributor

Describe your changes

  • Use bullet list to better distinguish distinct items.
  • Clarify limitations of URL pages (hidden or external considerations can be simplified to just: defined by URL or not)

There is a known bug #10572. In actuality, st.switch_page and st.page_link care more about the url_path than the page source. You can switch to the wrong page, or get rerouted to the homepage silently if you get a conflict in the URL pathname. If you use automatic URL paths inherited from the file and callable names, you probably won't notice, but as it stands, matching the url_path takes precedence. I just stated that you need to match both the source and path to avoid describing the current (unexpected) behavior of concocting a page with any source as long the the url_path matches where you want to go.


Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

Copilot AI review requested due to automatic review settings March 24, 2026 06:30
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for contributing to Streamlit! 🎈

Please make sure you have read our Contributing Guide. You can find additional information about Streamlit development in the wiki.

The review process:

  1. Initial triage: A maintainer will apply labels, approve CI to run, and trigger AI-assisted reviews. Your PR may be flagged with status:needs-product-approval if the feature requires product team sign-off.

  2. Code review: A core maintainer will start reviewing your PR once:

    • It is marked as 'ready for review', not 'draft'
    • It has status:product-approved (or doesn't need it)
    • All CI checks pass
    • All AI review comments are addressed

We're receiving many contributions and have limited review bandwidth — please expect some delay. We appreciate your patience! 🙏

@snyk-io
Copy link
Copy Markdown
Contributor

snyk-io bot commented Mar 24, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Streamlit’s public API documentation to better explain URL-defined pages and multipage navigation behavior, mainly by restructuring parameter descriptions into clearer bullet lists and refining the stated limitations around internal vs external pages.

Changes:

  • Rewrites st.Page docstring sections to clarify what constitutes a page source (callable, Python file, or external URL) and how visibility affects access.
  • Expands st.page_link and st.switch_page docstrings to more explicitly describe acceptable page inputs for st.navigation vs pages/ directory apps.
  • Minor doc polish (e.g., capitalization of “URL”) and reformats the st.Page example into an RST code-block.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
lib/streamlit/navigation/page.py Refines st.Page docstring for page source types, visibility behavior, URL access note, and example formatting.
lib/streamlit/elements/widgets/button.py Updates st.link_button and st.page_link docs, especially the page parameter semantics and URL-page behavior.
lib/streamlit/commands/execution_control.py Updates st.switch_page docstring to clarify supported targets and st.navigation vs pages/ behavior.

Comment on lines +214 to +217
- ``StreamlitPage``: The source of the ``StreamlitPage`` and its
``url_path`` must match a page defined in ``st.navigation``. The
``StreamlitPage`` must be internal and can't be defined by a URL.
Use ``st.Page`` to craete a ``StreamlitPage`` object.
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring states that a StreamlitPage's source and url_path must both match a page defined in st.navigation, but the current implementation of StreamlitPage._script_hash is derived from url_path (calc_md5(self._url_path)), and st.switch_page uses only page._script_hash. This means navigation can resolve solely by url_path, and source mismatches can silently route to another page when url_paths collide (see issue #10572). Please adjust the documentation to reflect the current behavior or explicitly call out the limitation/bug around url_path conflicts.

Suggested change
- ``StreamlitPage``: The source of the ``StreamlitPage`` and its
``url_path`` must match a page defined in ``st.navigation``. The
``StreamlitPage`` must be internal and can't be defined by a URL.
Use ``st.Page`` to craete a ``StreamlitPage`` object.
- ``StreamlitPage``: The ``url_path`` of the ``StreamlitPage`` must
match the ``url_path`` of a page defined in ``st.navigation``. The
page's source is not validated when switching; if multiple pages
share the same ``url_path``, navigation will resolve based only on
the ``url_path`` and may not match the expected source. The
``StreamlitPage`` must be internal and can't be defined by a URL.
Use ``st.Page`` to create a ``StreamlitPage`` object.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a deliberate choice. It's confusing to describe the current behavior which is more of a bug, so we can state a technically stronger requirement to follow to avoid the unexpected behavior (and hopefully fix the behavior later to address the bug).

Copy link
Copy Markdown
Collaborator

@lukasmasuch lukasmasuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@lukasmasuch lukasmasuch added impact:users PR changes affect end users change:docs PR contains documentation change labels Mar 24, 2026
@lukasmasuch lukasmasuch enabled auto-merge (squash) March 24, 2026 18:45
@lukasmasuch lukasmasuch merged commit aec3ba8 into streamlit:develop Mar 24, 2026
64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:docs PR contains documentation change impact:users PR changes affect end users

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants