{"record":{"id":"17b4ba7f3d30bc25","repo":"reflex-dev/reflex","slug":"hybrid-property-self-property-name-of-state","errorCode":null,"errorMessage":"Hybrid property '{self.__property_name}' of state '{state_cls.__name__}' accessed backend-only var '{name}' while building its frontend value. Backend vars (prefixed with '_') exist only on the server and cannot be referenced from a hybrid property's frontend logic. Use a regular var, or provide a separate frontend implementation with '@{self.__property_name}.var'.","messagePattern":"Hybrid property '(.+?)' of state '(.+?)' accessed backend-only var '(.+?)' while building its frontend value\\. Backend vars \\(prefixed with '_'\\) exist only on the server and cannot be referenced from a hybrid property's frontend logic\\. Use a regular var, or provide a separate frontend implementation with '@(.+?)\\.var'\\.","errorType":"exception","errorClass":"HybridPropertyError","httpStatus":null,"severity":"error","filePath":"packages/reflex-base/src/reflex_base/vars/hybrid_property.py","lineNumber":52,"sourceCode":"            name: The attribute accessed on the state inside the hybrid property.\n\n        Returns:\n            The class-level value (e.g. a frontend var) from the state.\n\n        Raises:\n            HybridPropertyError: If a backend (underscore-prefixed) var is accessed.\n        \"\"\"\n        state_cls = self.__state_cls\n        if name in state_cls.backend_vars:\n            msg = (\n                f\"Hybrid property '{self.__property_name}' of state \"\n                f\"'{state_cls.__name__}' accessed backend-only var '{name}' while \"\n                f\"building its frontend value. Backend vars (prefixed with '_') exist \"\n                f\"only on the server and cannot be referenced from a hybrid property's \"\n                f\"frontend logic. Use a regular var, or provide a separate frontend \"\n                f\"implementation with '@{self.__property_name}.var'.\"\n            )\n            raise HybridPropertyError(msg)\n        return getattr(state_cls, name)\n\n\nclass HybridProperty(property):\n    \"\"\"A hybrid property that can also be used in frontend/as var.\"\"\"\n\n    # The optional var function for the property.\n    _var: Callable[[Any], Var] | None = None\n\n    def _get_var(self, owner: Any) -> Var:\n        \"\"\"Get the frontend Var for the property.\n\n        The ``owner`` is the object the property is accessed on at the var level:\n        either the class (for class-level access, e.g. ``State.full_name``) or an\n        ``ObjectVar`` (for attribute access on an object var, e.g. ``State.info.a_b``).\n        Attribute access on ``owner`` inside the getter/var function resolves to Vars.\n\n        Args:","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-base/src/reflex_base/vars/hybrid_property.py#L34-L70","documentation":"A rx.hybrid_property builds both a backend (Python) and a frontend (JS) value from one property. Its frontend implementation is traced through __getattr__ on the state class; if it references a backend-only var (name starting with '_'), there is no way to render that value on the client, so HybridPropertyError is raised.","triggerScenarios":"Defining a hybrid property whose getter accesses a backend var like `self._internal` (or `State._internal`) — e.g. `@rx.hybrid_property def display(self): return f\"{self._count}{self._suffix}\"` where `_suffix` is backend.","commonSituations":"Migrating a property that used private/internal state vars to hybrid_property; accidentally including a '_'-prefixed var in f-strings or expressions inside the property; assuming backend vars are readable in frontend rendering like in regular computed vars.","solutions":["Rename the backend var to a regular (non-underscore) var if it is safe to expose to the client.","Provide a separate frontend implementation with `@<property_name>.var` that only uses frontend-visible vars.","Move the backend-var logic into a separate backend computed var and have the hybrid property reference that result indirectly."],"exampleFix":"# before\nclass State(rx.State):\n    _token: str = \"\"\n    @rx.hybrid_property\n    def header(self) -> str:\n        return f\"Bearer {self._token}\"\n\n# after\nclass State(rx.State):\n    _token: str = \"\"\n    @rx.hybrid_property\n    def header(self) -> str:\n        return f\"Bearer {self.token}\"\n    @header.var(deps=[_token])\n    def header(self) -> str:\n        return f\"Bearer {self._token}\"  # backend-only path","handlingStrategy":"type-guard","validationCode":"def uses_only_frontend_vars(fn) -> bool:\n    import inspect\n    src = inspect.getsource(fn)\n    return \"._\" not in src.replace(\"self._var\", \"\")  # crude check for backend var refs","typeGuard":"def references_backend_var(name: str) -> bool:\n    return name.startswith(\"_\")","tryCatchPattern":null,"preventionTips":["Never reference '_'-prefixed vars inside hybrid_property getters.","Provide an explicit @<prop>.var frontend implementation when backend data is needed.","Review hybrid properties after renaming/marking vars backend."],"tags":["reflex","hybrid-property","backend-var","frontend"],"backgroundTag":"hybrid-property-backend-access","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}