Reflex Logo

Intro

Gallery

Hosting

Learn

Components

Recipes

API Reference

Onboarding

Api-reference

/

App

reflex.app.App

The main Reflex app that encapsulates the backend and frontend.

Every Reflex app needs an app defined in its main module.

# app.py
import reflex as rx

# Define state and pages
...

app = rx.App(
    # Set global level style.
    style={...},
    # Set the top level theme.
    theme=rx.theme(accent_color="blue"),
)
PropDescription
theme: Component = <RadixThemesTheme accentColor={`blue`} css={{...theme.styles.global[':root'], ...theme.styles.global.body}}/>

The global theme for the entire app.

style: Any

The global style for the app.

stylesheets: str

A list of URLs to stylesheets to include in the app.

overlay_component: Union = <function default_overlay_component at 0x7efeab761d00>

A component that is present on every page (defaults to the Connection Error banner).

error_boundary: Callable = <function default_error_boundary at 0x7efeab761c60>

Error boundary component to wrap the app with.

head_components: Component

Components to add to the head of every page.

sio: AsyncServer

The Socket.IO AsyncServer instance.

html_lang: str

The language to add to the html root tag of every page.

html_custom_attrs: str

Attributes to add to the html root tag of every page.

frontend_exception_handler: Callable = <function default_frontend_exception_handler at 0x7efeae32e840>

Frontend Error Handler Function

backend_exception_handler: Callable = <function default_backend_exception_handler at 0x7efeabbce5c0>

Backend Error Handler Function

SignatureDescription
add_page(self, component: 'Component | ComponentCallable', route: 'str | None' = None, title: 'str | None' = None, description: 'str | None' = None, image: 'str' = 'favicon.ico', on_load: 'EventHandler | EventSpec | list[EventHandler | EventSpec] | None' = None, meta: 'list[dict[str, str]]' = [])Add a page to the app. If the component is a callable, by default the route is the name of the function. Otherwise, a route must be provided.
get_load_events(self, route: 'str') -> 'list[EventHandler | EventSpec]'Get the load events for a route.
add_custom_404_page(self, component: 'Component | ComponentCallable | None' = None, title: 'str' = '404 - Not Found', image: 'str' = 'favicon.ico', description: 'str' = 'The page was not found', on_load: 'EventHandler | EventSpec | list[EventHandler | EventSpec] | None' = None, meta: 'list[dict[str, str]]' = [])Define a custom 404 page for any url having no match. If there is no page defined on 'index' route, add the 404 page to it. If there is no global catchall defined, add the 404 page with a catchall.
modify_state(self, token: 'str') -> 'AsyncIterator[BaseState]'Modify the state out of band.

Did you find this useful?

HomeGalleryChangelogIntroductionHosting