Skip to content

on_connect lifecycle hook for @rx.event #6229

Open

Description

@masenf

Summary

Replace on_hydrate and app-wide on_load with a first-class on_connect hook on the @rx.event decorator.

Details

When a client establishes a websocket connection, registered on_connect handlers fire automatically — no need for page-level on_load lists or the implicit on_hydrate mechanism. on_connect also fires on any initial session-establishing call.

This simplifies the lifecycle model:

  • Explicit: no hidden on_hydrate magic
  • Discoverable: registered in the same global event list as all other handlers
  • Composable: multiple handlers, priority ordering, same semantics as other registered events

Works naturally with the EventHandler redesign (1b) — on_connect handlers are just event handlers with a lifecycle trigger.

Part of the Reflex Framework Roadmap — Section 1j.

Activity

  1. linear commented on Mar 25, 2026

    @linear
  2. added
    roadmaphttps://github.com/reflex-dev/reflex/issues/2727
    on Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementAnything you want improvedroadmaphttps://github.com/reflex-dev/reflex/issues/2727

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions