✨ Announcing our seed funding led by Lux Capital! Read more about it on our blog
DocsBlogChangelog

Search documentation...

/

Star

12k+

[ Learn ]

[ Concepts ]

[ Reference ]

App


reflex.app.App
A Reflex application.

Class Fields


FieldDescription

Fields


FieldDescription
pages A map from a page route to the component to render.
stylesheets A list of URLs to stylesheets to include in the app.
api The backend API object.
sio The Socket.IO AsyncServer.
socket_app The socket app.
state The state class to use for the app.
state_manager Class to manage many client states.
style The styling to apply to each component.
middleware Middleware to add to the app.
load_events List of event handlers to trigger when a page loads.
admin_dash Admin dashboard
event_namespace The async server name space
overlay_component A component that is present on every page.
background_tasks Background tasks that are currently running

Methods


SignatureDescription
__init__(self, *args, **kwargs)Initialize the app.
__repr__(self) -> 'str'Get the string representation of the app.
__call__(self) -> 'FastAPI'Run the backend api instance.
add_default_endpoints(self)Add the default endpoints.
add_cors(self)Add CORS middleware to the app.
preprocess(self, state: 'State', event: 'Event') -> 'StateUpdate | None'Preprocess the event. This is where middleware can modify the event before it is processed. Each middleware is called in the order it was added to the app. If a middleware returns an update, the event is not processed and the update is returned.
postprocess(self, state: 'State', event: 'Event', update: 'StateUpdate') -> 'StateUpdate'Postprocess the event. This is where middleware can modify the delta after it is processed. Each middleware is called in the order it was added to the app.
add_middleware(self, middleware: 'Middleware', index: 'int | None' = None)Add middleware to the app.
_generate_component(component: 'Component | ComponentCallable') -> 'Component'Generate a component from a callable.
add_page(self, component: 'Component | ComponentCallable', route: 'str | None' = None, title: 'str' = 'Reflex App', description: 'str' = 'A Reflex app.', image='favicon.ico', on_load: 'EventHandler | EventSpec | list[EventHandler | EventSpec] | None' = None, meta: 'list[dict[str, str]]' = [], script_tags: 'list[Component] | None' = None)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.
_check_routes_conflict(self, new_route: 'str')Verify if there is any conflict between the new route and any existing route. Based on conflicts that NextJS would throw if not intercepted. Raises: ValueError: exception showing which conflict exist with the route to be added
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
setup_admin_dash(self)Setup the admin dash.
get_frontend_packages(self, imports: 'Dict[str, set[ImportVar]]')Gets the frontend packages to be installed and filters out the unnecessary ones.
compile(self)Compile the app and output it to the pages folder.
modify_state(self, token: 'str') -> 'AsyncIterator[State]'Modify the state out of band.
_process_background(self, state: 'State', event: 'Event') -> 'asyncio.Task | None'Process an event in the background and emit updates as they arrive.
← BrowserBase →

Copyright © 2023 Pynecone, Inc.