Skip to content

Components

reactpy_router.route(path, element, *routes)

Create a route with the given path, element, and child routes.

Parameters:

Name Type Description Default
path str

The path for the route.

required
element Any | None

The element to render for this route. Can be None.

required
routes Route

Additional child routes.

()

Returns:

Type Description
Route

The created route object.

Create a link with the given attributes and children.

Parameters:

Name Type Description Default
attributes dict[str, Any]

A dictionary of attributes for the link.

required
*children Any

Child elements to be included within the link.

()

Returns:

Type Description
Component

A link component with the specified attributes and children.

reactpy_router.navigate(to, replace=False, key=None)

Navigate to a specified URL.

This function changes the browser's current URL when it is rendered.

Parameters:

Name Type Description Default
to str | int

The target URL to navigate to, or an integer indicating the relative position in the browser's history stack (e.g., -1 to go back, 1 to go forward). See History.go <https://developer.mozilla.org/en-US/docs/Web/API/History/go>_.

required
replace bool

If True, the current history entry will be replaced with the new URL. Ignored when to is an integer. Defaults to False.

False

Returns:

Type Description
Component

The component responsible for navigation.

Authors: Mark Bakhit