Releases: reflex-dev/reflex
v0.5.4
Improvements
- [REF-2956]Fail When Backend port or frontend port is explicitly provided and the port is in use by @ElijahAhianyo in #3432
- promote toast to main namespace by @Lendemor in #3422
- [REF-2977] [REF-2982] Plotly: Merge layout prop and automatic darkmode by @masenf in #3442
- Recharts supporting radix color, add event triggers by @HongyuHansonYao in #3430
- [REF-3009] type transforming serializers by @benedikt-bartscher in #3227
- default color_mode is now system color by @Lendemor in #3457
- Refactor: make better/less use of dict.keys() calls by @alexandermorgan in #3455
Bug Fixes
- [REF-2602]Do not suppress import errors in rxconfig by @ElijahAhianyo in #3434
- [REF-3006] Inline code rendered in rx.markdown has extra trailing space by @masenf in #3426
- Address an issue with pydantic v2 models as Vars by @kroo in #3396
- state.js: set event_processing = false when websocket connects by @masenf in #3443
- [REF-2879] Make client_state work without global refs (local only) by @masenf in #3379
Other Changes
- PR zh/zh_tw readme update for relex 0.5.2 by @milochen0418 in #3415
- fix: correct zh_tw and zh_cn README for hyperlink issues by @milochen0418 in #3440
- clean up hooks and update component to use add_hooks by @Lendemor in #3439
- fix warning about props by @Lendemor in #3451
- Webdriver ArgOptions improvements by @benedikt-bartscher in #3429
- [bug] Avoid deleting endpoint port when running on Replit by @blast-hardcheese in #3447
- [REF-3013] Only run
pyi_generator
on files in reflex/components or reflex/init.py by @masenf in #3452 - Pass _var_is_string parameter to Var.create by @masenf in #3470
- Override _var_is_string when handling str literals by @masenf in #3473
- compat: do not patch pydantic if the installed version starts with "1." by @masenf in #3482
New Contributors
- @blast-hardcheese made their first contribution in #3447
- @kroo made their first contribution in #3396
- @alexandermorgan made their first contribution in #3455
Full Changelog: v0.5.3...v0.5.4
v0.5.3
New Features
- External assets by @abulvenz in #3220
- add mapping between client_token and socket id by @Lendemor in #3388
- add config knob for react_strict_mode by @Lendemor in #3389
- [REF-2202] Implement event handlers for Plotly by @masenf in #3397
Improvements
- Radix Themes + Tailwind Harmony by @masenf in #3355
- Explicit deps and interval for computed vars by @benedikt-bartscher in #3231
- Add domain prop for the PolarRadiusAxis component by @TG199 in #3349
- [REF-2710]Recommend Running with
REFLEX_USE_NPM=1
if npm run fails after installing packages with bun. by @ElijahAhianyo in #3399 - refactor: radix section default size by @Jishnu-Nandhiath in #3406
- [REF-2978] Ignore Redis config_set for AWS ElastiCache by @masenf in #3401
- [REF-1356] Track changes applied to
Base
subclass via helper method. by @masenf in #2242 - include resize and radius props to the text area component by @carlosabadia in #3383
Each component import is now independently lazy
Save time by avoiding imports for components which are not used in the app.
- [REF-2821]Improve Dynamic Imports by @ElijahAhianyo in #3345
Bug Fixes
- Layout property not pushed through on rx.plotly by @HongyuHansonYao in #3394
Other Changes
- [REF-2895]Benchmarks getting skipped on merge by @ElijahAhianyo in #3369
- Updated in/readme.md with current readme by @sagarhedaoo in #3333
- update image for readme by @tgberkeley in #3395
New Contributors
- @sagarhedaoo made their first contribution in #3333
- @TG199 made their first contribution in #3349
- @HongyuHansonYao made their first contribution in #3394
- @carlosabadia made their first contribution in #3383
Full Changelog: v0.5.2...v0.5.3
v0.5.2
New Features
Lifespan Tasks
A lifespan task is either a coroutine which runs while the backend server is running and is cancelled when the server stops, or it can be an asynccontextmanager
in which case it will run at server startup until yield
is called, then it will resume as the server is shutting down. In either case, the task is started and stopped during hot reload.
Any keyword arguments passed to app.register_lifespan_task
will be passed to the coroutine/contextmanager. If the coroutine takes a parameter called app
, this will be an instance of the underlying FastAPI object.
import asyncio
from contextlib import asynccontextmanager
def fake_answer_to_everything_ml_model(x: float):
return x * 42
ml_models = {}
@asynccontextmanager
async def setup_model(app: FastAPI):
# Load the ML model
ml_models["answer_to_everything"] = fake_answer_to_everything_ml_model
yield
# Clean up the ML models and release the resources
ml_models.clear()
async def long_running_task(foo, bar):
print(f"Starting {foo} {bar} task")
some_api = SomeApi(foo)
try:
while True:
updates = some_api.poll_for_updates()
other_api.push_changes(updates, bar)
await asyncio.sleep(5) # add some polling delay to avoid running too often
except asyncio.CancelledError:
some_api.close() # clean up the API if needed
print("Task was stopped")
app = rx.App()
app.register_lifespan_task(setup_model)
app.register_lifespan_task(long_running_task, foo=42, bar=os.environ["BAR_PARAM"])
Improvements
- Catch more errors in frontend/backend by @picklelo in #3346
- Use twine environment variables if set by @ericwb in #3353
- add style for orientation=vertical in tabs by @Lendemor in #3332
- Added config for number of gunicorn workers by @Snaipergelka in #3351
- feat: Optionally comparing fields in Var.contains, e.g. on rx.Base based types. by @abulvenz in #3375
Bug Fixes
- fix rx.cond with ComputedVars and use union type by @benedikt-bartscher in #3336
- do not check attribute type for var internals by @benedikt-bartscher in #3357
- [REF-2915] ComponentState subclasses are always treated as mixin by @masenf in #3372
- Fix regression when subclassing a ComponentState subclass.
- set config.deploy_url during AppHarness tests by @benedikt-bartscher in #3359
- [REF-2878] Map fontFamily to fontFamily and --default-font-family by @masenf in #3380
- url quote the str data passed to rx.download by @masenf in #3381
Readme Updates
- update README to use 0.5.0 by @Lendemor in #3313
- #3321: Update Chinese README.md by @seewindcn in #3350
- Update Spanish README.md by @boterop in #3330
- Update Korean README.md by @owlur in #3337
Other Changes
- Add some minimal validation of pyproject.toml by @ericwb in #3339
- Suppress runtime warnings by @picklelo in #3354
New Contributors
Full Changelog: https://github.com/reflex-dev/reflex/compare/v0.5.1..v0.5.2
v0.5.1
New Features
- Connection Error modal is now a dismissable toast by @Lendemor in #3242
- rx._x.client_state: react useState Var integration for frontend and backend by @masenf in #3269
- Work in progress, API subject to change
- Support replacing route on redirect by @masenf in #3072
Improvements
- rx.accordion customizability overhaul by @masenf in #3266
- #3185 fix tailwind.config.js: support corePlugins, important, prefix,β¦ by @seewindcn in #3260
- FIX - Error: img is a self-closing tag and must neither have children nor use dangerouslySetInnerHTML. by @Yummy-Yums in #3307
- Get
action
,cancel
,on_dismiss
andon_auto_close
working for rx._x.toast by @masenf in #3216 - typed mixins and ComponentState by @benedikt-bartscher in #3196
- [REF-2787] add_hooks supports Var-wrapped hooks by @masenf in #3248
- Add end line in .gitignore when
reflex init
by @boterop in #3309 - allow passing kwargs and options to selenium webdriver by @benedikt-bartscher in #2894
Bugfixes
- Only import PyiGenerator when needed by @masenf in #3291
- Typo in contact email address by @ericwb in #3292
- properly replace ComputedVars by @benedikt-bartscher in #3254
- throw error for componentstate in foreach by @Lendemor in #3243
Dependencies
- Bump Bun version by @ElijahAhianyo in #3281
Other Changes
- [REF-2776] enable telemetry for frontend package download subprocess by @martinxu9 in #3270
- [REF-2774] Add ReflexError and subclasses, send in telemetry by @martinxu9 in #3271
- [REF-2774] Send runtime error in telemetry by @martinxu9 in #3276
- Automatically label bug report issues with bug tag by @ericwb in #3288
- [REF-2803]Add imports benchmarks by @ElijahAhianyo in #3272
- Mirgrate from pip to uv by @ericwb in #3285
- Adds dependency review action to verify allowed licensed dependencies by @ericwb in #3306
New Contributors
- @seewindcn made their first contribution in #3260
- @ericwb made their first contribution in #3288
- @boterop made their first contribution in #3309
Full Changelog: v0.5.0.post1...v0.5.1
v0.5.0.post1
Escape Hatch to avoid Bun on Windows
These exceptions only apply to Windows native platform (not WSL)
- [REF-2814]Throw Warning for Projects Created in OneDrive on Windows (#3304)
- Skip bun when project path contains "onedrive"
- Skip bun when
REFLEX_USE_NPM=1
(environment variable)
Full Changelog: v0.5.0...v0.5.0.post1
v0.5.0
Breaking Changes
Radix Themes 3.0
rx.badge
now hassize="3"
available, and sizes"2"
and"1"
have been adjusted accordinglyrx.input.root
andrx.input.input
are deprecated. Just userx.input
as the root. It acceptsrx.input.slot
as a child.- [REF-2789] Graceful deprecation of
rx.input.root
andrx.input.input
#3249
- [REF-2789] Graceful deprecation of
Previously Deprecated Features Removed
get_asset_path
removed- passing
state
torx.App
- passing
script_tags
torx.App.add_page
- passing
custom_styles
torx.markdown
(usecomponent_map
instead) rx.State
getters removed (useself.router
instead)get_token
get_sid
get_headers
get_client_ip
get_current_page
get_query_params
get_cookies
Remove deprecations for 0.5.0 by @picklelo in #3222
New Features
Radix Themes 3.0
rx.spinner
- new component for indeterminate loadingrx.skeleton
- new component for placeholder loadingloading
prop available forrx.button
rx.icon_button
rx.spinner
andrx.skeleton
-- useloading=State.is_loading
instead of usingrx.cond
rx.data_list
- new component for showing key value pairsrx._x.progress
- experimental radix themes progress component, supportsduration
for indeterminate progress.
Radix 3.0 by @Lendemor in #3159
New Public API for wrapping Components
To make wrapping components easier and less error prone, the following functions should be overridden when wrapping components:
add_style
- return anrx.style.Style
for default component stylesadd_imports
- return a dictionary of{"[email protected]": {"tag1", "tag2", "tag3"}}
of required imports -- it will automatically be merged with the other component imports.add_hooks
- return a list of javascript snippets that will go inside the component function -- it will be deduped automatically with any other hooksadd_custom_code
- return a list of javascript snippets that will go inside the module for each page the component is included in.
With these new methods, Reflex will internally call them for each parent class your component inherits from, so there is no need to call super().add_*
or do any merging yourself.
- [REF-2523] Implement new public Component API by @masenf in #3203
- add_style api by @Lendemor in #3202
State.setvar(var_name, value)
A less magic version of the automatic State.set_x
setter functions which accept the var_name
as a string.
Experimental Toast Component
def try_some_toast():
return rx.fragment(
rx.button("π₯", on_click=rx._x.toast.info("Cheers"), variant="outline"),
rx._x.toast.provider(),
)
Generic .throttle
and .debounce
for all Event types
class ThrottleState(rx.State):
last_event: datetime.datetime = datetime.datetime.now()
def handle_mouse_move(self):
self.last_event = datetime.datetime.now()
def throttle_example():
return rx.box(
ThrottleState.last_event,
background_color=rx.color("red", 7),
width="500px",
height="500px",
on_mouse_move=ThrottleState.handle_mouse_move.throttle(500), # one event every 500ms
)
rx.container
new prop stack_children_full_width
For a nice streamlit-like wide layout, use the following snippet:
def index():
return rx.container(
rx.vstack(content()),
stack_children_full_width=True,
)
This will cause all vstack/hstack children and most stack child components to have width="100%"
automatically, which provides a nice aesthetic for many apps without applying CSS to individual components.
- [REF-2574] Default width for Stack (+children) and default padding for container by @masenf in #3104
Improvements
Unify on ruff-format
- ruff-format: unify Black with Ruff
v0.1
by @Borda in #2837 - sync ruff version in pyproject.toml with the precommit one by @Lendemor in #3150
Error Messages
- [REF-2636]Improve Error message for unsupported event trigger by @ElijahAhianyo in #3147
- prevent shadowing by @Lendemor in #3221
- Better error when a computed var has the same name as an existing state var.
- [REF-2643]Throw Errors for duplicate Routes by @ElijahAhianyo in #3155
- [REF-2622]Throw warning for incompatible uvicorn version on windows by @ElijahAhianyo in #3246
rx.color_mode
changes
rx.color_mode.button
now has built in positioning prop for floating button
Default style for rx.upload
- Refactor upload component and add styled upload component by @Ifechukwu001 in #3035
Use Alembic Batch Mode for reflex db makemigrations
This improves compatibility with the default sqlite database when re-typing columns.
README
- add color dalle code example by @tgberkeley in #3108
- a little correction in the "es" docs by @JLDev-coder in #3127
- Add Japanese README.md file by @PeterYusuke in #3234
Miscellaneous
- add default underline for links by @Lendemor in #3148
- Expose
color_scheme
on TabsTrigger by @masenf in #3112 - update blank template by @Lendemor in #3219
- Clean up config and app API by @picklelo in #3197
- Fixed unused kwargs in reflex.App by @Snaipergelka in #3170
- Now able to pass a custom
SocketIO
instance
- Now able to pass a custom
Bugfixes
- [REF-2587] Ignore top-level theme appearance by @masenf in #3119
- avoids "flickering" when the top-level appearance differs from user selected mode
- [REF-2619] Re-init when the template is out of date by @masenf in #3121
- Fixed app name validation by @Snaipergelka in #3146
- extend rx.input allowed types by @Lendemor in #3149
- [REF-2682] Foreach over dict uses Tuple arg value by @masenf in #3160
- Improve nested foreach when dict has complex values
- Update CodeBlock class to accept rx.color in custom_style by @khhan0130 in #3168
- Windows
--frontend-only
fix ctrl + c by @ElijahAhianyo in #3181 - [REF-2676][REF-2751]Windows Skip ARM devices on bun install + Telemetry by @ElijahAhianyo in #3212
- icon_button: Icon size should be specified as int pixels, not str by @masenf in #3247
- copy background task marker by @benedikt-bartscher in #3255
- Can now define background tasks in a state mixin
- Dynamic NoSSRComponent properly renders in prod mode when using State/event handlers
Dependencies
- Bump bun version to 1.1.5 by @ElijahAhianyo in #3176
- Windows Pin Bun version by @ElijahAhianyo in #3192
- Windows Pin Version followup (Use Windows Install Link) by @ElijahAhianyo in #3193
- [REF-2764] dep update 0.5.0 by @masenf in #3245
- gunicorn 22.0.0 with security fix
Other Changes
- separate DECORATED_PAGES per reflex app by @benedikt-bartscher in #3102
- fix: args issue in
__init__
of App class by @nautics889 in #3141 - [REF-2620] Fallback to npm (not bun) by @masenf in #3138
- pin macos version for CI by @Lendemor in #3145
- [REF-2618] Send template info in init telemetry event by @martinxu9 in #3153
- Integration testing: Firefox compatibility by @masenf in #3162
- Improved get_attribute_access_type by @benedikt-bartscher in #3156
- custom component install command to install current project in editable mode by @martinxu9 in #3200
- migrate deprecated redis.close to redis.aclose by @benedikt-bartscher in #3199
- allow optional props with None default value by @benedikt-bartscher in #3179
- Allow StatefulComponent to also be rendered via
__str__
by @m...
v0.4.9
New Features
Improvements
- Simplify
run_process_with_fallback
logic by @masenf in #3089 - Use Fallback command on all platforms by @ElijahAhianyo in #3099
- allow set in var.contains by @martinxu9 in #3113
Bug Fixes
- [REF-2586] Pass child event_trigger through DebounceInput by @masenf in #3092
on_key_down
/on_key_up
work with controlled inputs
- [REF-2589] Use errors='replace' with subprocess by @masenf in #3096
- Avoid UnicodeDecodeError on windows
- [REF-2587] Ignore top-level theme appearance (#3119)
Experimental
Other Changes
- do not clear all decorated pages during AppHarness tests by @benedikt-bartscher in #3093
- improve auto-generated AppHarness app_name with partials by @benedikt-bartscher in #3088
- app_source can be partial by @benedikt-bartscher in #3100
- pin react-focus-lock to 2.11.3 (#3123)
Full Changelog: v0.4.8...v0.4.9
v0.4.8.post1
Pin react-focus-lock to 2.11.13 #3123
v0.4.8
New Features
new transpile_packages
field in rx.Component
For packages on npm which are not exported as modules, these can now be transpiled by Next.JS and used directly.
Improvements
Use bun
as a package manager on windows
Much faster package installation on windows!
x64 only (no x86 or ARM support)
Upload with no files selected still calls event handler
Note: you need to specify a default value for your files parameter to take advantage of this change.
- Fix For When user selects Empty files using File Upload by @Yummy-Yums in #3051
Enum types are now serialized to their value
- added serializer for enums by @wassafshahzad in #3058
Automatic tuple unpacking also works for Component children
- [REF-2524]Tuple unpacking should apply at component level by @ElijahAhianyo in #3062
Bug Fixes
- minimal fix for upload_url in rx.download by @Lendemor in #3073
- Force pydantic v1 for sqlmodel compatibility by @masenf in #3026
- Fix annotated EventHandler by @masenf in #3076
Experimental
Other Changes
- chore: fix some typos in comments by @hugehope in #3071
- fix: removed .git in template URL by @wassafshahzad in #3049
New Contributors
Full Changelog: v0.4.7...v0.4.8
v0.4.7
New Features
New reflex init
templates
We've added 4 new base templates to reflex init
.
(0) blank (https://blank-template.reflex.run) - A minimal template
(1) dashboard (https://dashboard.reflex.run) - A dashboard with tables and graphs
(2) chat (https://chat.reflex.run) - A ChatGPT clone
(3) sidebar (https://sidebar-template.reflex.run) - A template with a sidebar to navigate pages
You can also specify the template directly
reflex init --template chat
- Update sidebar temp by @Alek99 in #2959
- Support reflex app creation from templates from github by @martinxu9 in #2490
Use any Reflex app on Github as an initial template
reflex init
now also supports passing in any Github url as a template. Currently the Reflex app must be in the root of the Github directory (meaning the rxconfig.py
should be in the root.
reflex init --template https://github.com/reflex-dev/reflex-chat
- Support reflex app creation from templates from github by @martinxu9 in #2490
reflex run
will automatically init the app when required
Previously when updating versions of Reflex or cloning an existing Reflex app, you would have to run reflex init
before you can reflex run
. From 0.4.7, reflex init
is only required the very first time you create an app. If you are missing a .web
folder or there's a new version of Reflex, reflex run
and reflex export
will automatically init
the app for you.
rx.logo()
component to display the Reflex logo
Show Built with Reflex logo.
rx.logo()
- adding a reflex logo component by @tgberkeley in #2994
Reflex Experimental Namespace
We've introduced a new rx._x
namespace where we will be putting experimental features for early testers before they go into general release. This will help us make sure new features have time to mature with real users before we make them public
Improvements
None
can be passed in as a component prop and it will be skipped
- Logic for removing the 'None' property along with its corresponding test cases by @AmanSal1 in #2969
Leaving a trailing comma on a reflex component won't throw an error anymore as we unpack the tuple
- Unpack component tuples in a fragment by @ElijahAhianyo in #2985
Bug Fixes
- [REF-2425] Reduce unnecessary CI runs by @martinxu9 in #2966
- adjust share command prompt by @martinxu9 in #2965
- Windows uvicorn bug fix by @sid-38 in #2954
- use dict instead of set to store hooks by @Lendemor in #2995
- Added custom_attrs to the list of trigger props by @SwarajBaral in #2980
- Exclude .web dir when running uvicorn by @ElijahAhianyo in #2986
- Fix typo in page.py by @thphuc in #3001
Misc
- Lendemor/improve coverage by @Lendemor in #2988
- Include architecture post in readme by @picklelo in #2993
- Remove extra spaces in the keywords in pyproject.toml template by @martinxu9 in #2990
- add logo to blank template by @tgberkeley in #3014
- [REF-2296] Rename recursive functions by @martinxu9 in #2999
- [REF-2303] Update custom component template for new API by @martinxu9 in #3007
- remove types-tabulate from dev dependencies by @martinxu9 in #2977
New Contributors
- @AmanSal1 made their first contribution in #2969
- @sid-38 made their first contribution in #2954
- @SwarajBaral made their first contribution in #2980
- @thphuc made their first contribution in #3001
Full Changelog: v0.4.6...v0.4.7