✨ Announcing our seed funding led by Lux Capital! Read more about it on our blog
DocsBlogChangelog

Search documentation...

/

Star

12k+

[ Learn ]

[ Concepts ]

[ Reference ]

Special Events


Reflex has some special built-in events that can be attached to event triggers or returned from event handlers like any other event.

console_log


Do a console.log on the browser.
def index():
    return rx.button(
        "Log", on_click=rx.console_log("Hello World!")
    )

redirect


Redirect to a new path.
def index():
    return rx.button(
        "Redirect",
        on_click=rx.redirect(
            "/docs/api-reference/special-events"
        ),
    )

set_clipboard


Set the text in content in the clipboard.
def index():
    return rx.button(
        "Copy 'Hello World' to clipboard",
        on_click=rx.set_clipboard("Hello World"),
    )
Set a cookie on the frontend.
def index():
    return rx.button(
        "Set cookie",
        on_click=rx.set_cookie("key", "my_value"),
    )
Remove a cookie on the frontend.
def index():
    return rx.button(
        "Remove cookie", on_click=rx.remove_cookie("key")
    )

set_local_storage


Set a value in the local storage on the frontend.
def index():
    return rx.button(
        "Set Local Storage",
        on_click=rx.set_local_storage("key", "my_value"),
    )

remove_local_storage


Set a value in the local storage on the frontend.
def index():
    return rx.button(
        "Remove Local Storage",
        on_click=rx.remove_local_storage("key"),
    )

clear_local_storage


Set a value in the local storage on the frontend.
def index():
    return rx.button(
        "Clear all Local Storage",
        on_click=rx.clear_local_storage(),
    )

set_value


Set the value of a ref.
def index():
    return rx.hstack(
        rx.input(id="input1"),
        rx.button(
            "Erase", on_click=rx.set_value("input1", "")
        ),
    )

window_alert


Create a window alert on the browser.
def index():
    return rx.button(
        "Alert", on_click=rx.window_alert("Hello World!")
    )
← Event TriggersBrowser →

Copyright © 2023 Pynecone, Inc.