> For the complete documentation index, see [llms.txt](https://adospace.gitbook.io/reactorui/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://adospace.gitbook.io/reactorui/guide/components-with-a-state/component-context.md).

# Component Context

Any derived `RxComponent` class can access a Context property that returns a `RxContext` object shared with any other component in the visual tree.

An `RxContext` is essentially a `Dictionary<string, object>` that you can use to store or retrive global variables: for example a service container object or current logged user.

`RxApplication` can be created also passing a value in the Context of the root component; for example in the following code we are passing a service provider object to the root component:

```csharp
ServiceProvider = RegisterServices();
_app = RxApplication.Create<ShellComponent>(this)
    .WithContext("ServiceProvider", ServiceProvider)
```

Any component under root component can access the context:

```csharp
var serviceProvider = (IServiceProvider)Context["ServiceProvider"];
```
