How we can extract # URL fragments or complete URL in new versions of streamlit


i was able to extract fragments using streamlit-url-fragment module in streamlit version 1.8.1 but unable to do the same in ver 1.14.1.
This is happening due to auto refresh that is happening in browser address bar and removing url fragments automatically.

Steps to reproduce

Try Passing URL fragments for example below -

1 Like

Hey @Ketan_Sharma, can you share a code snippet so we can try to reproduce this issue?

1 Like

Hi @Caroline,
Thank you for looking into the issue, please find the code snippet below -

import streamlit as st
from streamlit_url_fragment import get_fragment
if __name__ == "__main__":
    # -- Header Information"Loading page configurations")
        page_title='Page 1',
    current_value = get_fragment()
    if current_value is None:
    print("current_value", current_value)

Here i am trying to extract # fragments from the url.
Sample URL -

Ketan Sharma

Hi @Caroline - Any updates on this issue?

Is there a reason you’re using 1.14 rather than the most recent release? Also, please check out our guide on posting questions and update your code snippet to be formatted properly.

@Caroline - I tried it with the most recent Streamlit version also, but was facing the same issue.
Were you able to reproduce the issue i explained?
Quick Question - is there a way to get Request URL in Streamlit ?


We’ve experienced the same issue. We need to get a token from the fragment, but unfortunately anything after the # in the url is removed when the page loads.
Unfortunately even after many attempts we were unable to fix it, and so we had to reverted back to 1.9, which is the latest version without the issue.

Anyway you can use URL parameters instead? st.experimental_get_query_params - Streamlit Docs

@dclin - Method you mentioned will get you query parameters not # fragments.


@dclin Same for me as for @Ketan_Sharma, our token retrieval only supports returning the token as a fragment, not as a query param. Unfortunately there seems to be no way to disable Streamlit from removing the fragments.

Update: updating streamlit to 1.21 fixes it. It no longer removes the fragment. (we were using 1.19 before)