User validates by clicking a streamlit link


I am looking for a way that I can send a user a validation link that, when clicked on in Streamlit, causes an action to be taken. For example:

dear user,

click on this validation link to activate your account.


I can figure out how to make a target using an anchor to a header

st.subheader(“validation test”, anchor=“validation_link/secretkey”)

but I’m stuck on how to make clicking the link trigger an action (in this case, setting a database to “confirmed”).

1 Like

Hi @fredzannarbor :wave:

You can wrap any hyperlink via markdown, e.g. have a look at this code where several hyperlinks were added:

import streamlit as st
        "###### Made in [![this is an image link](](, with :heart: by [@DataChaz]( &nbsp | &nbsp [![Follow](]( &nbsp | &nbsp [![this is an image link](]("

Let me know if that helps?


Almost, but not quite! I need to execute some logic based on the fact that the hyperlink was clicked. In Flask this is accomplished by creating a route to receive the confirmation click.

Something like this:

# app/auth/

from import send_congrats_email

@bp.route('/register', methods=['GET', 'POST'])
def register():
    if current_user.is_authenticated:
        return redirect(url_for('main.index'))
    form = RegistrationForm()
    if form.validate_on_submit():
        user = User(,
        flash('Check your email for our congrats message')
        return redirect(url_for('auth.login'))
    return render_template('auth/register.html', title='Register',

Maybe all I need to do here is create a target container that holds a form. Will try it.

1 Like

In case this saves someone else some time, this seems to work. I send an email including the URI http://localhost:8501/#validate

          with st.container():
                    st.subheader('Validate', anchor='validate')
                    with st.form(key='form_header'):
                        submit = st.form_submit_button('Validating my email address')
                    if submit:
                        # do database action
                        st.write('Your email has been validated!')