LogixProvider
API Reference for LogixProvider
LogixProvider (also known as RuntimeProvider) is the root component for a Logix app. It provides the Runtime context to the component subtree.
Usage
import { RuntimeProvider } from '@logixjs/react'
import * as Logix from '@logixjs/core'
import { Layer } from 'effect'
import { RootImpl } from './root-module'
// Recommended: build an app-level Runtime via Root ModuleImpl + Logix.Runtime.make
const appRuntime = Logix.Runtime.make(RootImpl, {
layer: Layer.empty, // You can also merge HttpClient/Config layers here
})
function Root() {
return (
<RuntimeProvider runtime={appRuntime}>
<App />
</RuntimeProvider>
)
}API
<RuntimeProvider runtime>
runtime: anyManagedRuntimeinstance (fromeffect). In typical app/page scenarios, this is usually the return value ofLogix.Runtime.make(root, { layer })(rootcan be a program module or its.impl).- Recommended: define an app-level runtime with Root ModuleImpl +
Logix.Runtime.make, then pass it intoRuntimeProvider. - Exception: if your project already creates a generic
ManagedRuntimeelsewhere (e.g. as a pure Effect host and you don’t care about module trees), you can pass it directly.
- Recommended: define an app-level runtime with Root ModuleImpl +
For how to choose between
Logix.Runtime.makeand plainManagedRuntime.make, see the “Runtime and ManagedRuntime” doc.
Context
RuntimeProvider provides the following via React Context:
- Runtime: the global Effect runtime.
- Scope: the root Scope.
- Store: the global state store.
All descendant components (via useModule, etc.) automatically connect to this Runtime.