For AI agents: the complete documentation index is at llms.txt. Markdown versions are available by appending .md or sending Accept: text/markdown.
Reflex Logo
Docs Logo
Api Reference

/

Var

Var

reflex_base.vars.base.Var

Base class for immutable vars.

Methods

SignatureDescription
equals(other: Var) -> boolCheck if two vars are equal.
create(value: OTHER_VAR_TYPE, _var_data: Optional[VarData] = None) -> Var[OTHER_VAR_TYPE]Create a var from a value.
to(output: type[OUTPUT] | GenericType, var_type: Optional[GenericType] = None) -> VarConvert the var to a different type.
guess_type() -> VarGuesses the type of the variable based on its `_var_type` attribute.
bool() -> BooleanVarConvert the var to a boolean.
is_none() -> BooleanVarCheck if the var is None.
is_not_none() -> BooleanVarCheck if the var is not None.
to_string(use_json: bool = True) -> StringVarConvert the var to a string.
js_type() -> StringVarReturns the javascript type of the object. This method uses the `typeof` function from the `FunctionStringVar` class to determine the type of the object.
range(first_endpoint: int | NumberVar, second_endpoint: Optional[int | NumberVar] = None, step: Optional[int | NumberVar] = None) -> ArrayVar[Sequence[int]]Create a range of numbers.
Built with Reflex