DocsBlog

Get Started

Components

Data Grid

Signals

Styling

Theming

↑↓Navigate
↵Select
EscClose
  • 1.8.0

  • Day

    Night

    Preview

    Switch mode
  • cerberus

    acheron

    elysium

    oceanus

Get Started
Components
Data Grid
Signals
Styling
Theming

Get started

OverviewReactivityData FetchingGlobal Stores

Primitives

Creating SignalsCreating QueriesCreating MutationsComputing Signal ValuesCreating EffectsContextual Signal StoresBatch UpdatesCleanup EffectsUntrack Signals

Hooks

Using QueriesUsing MutationsReading Primitive SignalsUsing SignalsUsing Store Instances

Components

Reactive Text

Contextual Signal Stores

Learn how to create Context-based signal stores in React.

  • source
View as Markdown
Open this page in Markdown
Anthropic
Open in Claude
Ask questions about this page
OpenAI
Open in ChatGPT
Ask questions about this page
import { createStoreContext } from '@cerberus/signals'

Introduction

With Cerberus Signals, you can create global (signal-based) stores that manage data and actions in a single place. Sometimes, you may want this scoped to an application or component instance.

For this use case, we have the createStoreContext primitive.

This primitive will create both a Provider and getter hook heavily typed to the store data passed in.

Loading example...

In this demo we have a global store that manages signals. We then generate the context APIs and pass the MyStore type so we obtain strict type accountability.

In our main component we use the StoreProvider and pass our store to the createStore prop.

In the child component we utilize the useStore hook to gain access to the store.

Note

Remember that anytime you want to read a signal from a primitive - you need to either use ReactiveText or useRead to subscribe to the signal.

API

createStoreContext doesn't accepts the following props:

PropertyTypeDescription
namestringOptional. The name of the store to assign as the context display name.

Return

createStoreContext returns an Object with two properties:

PropertyTypeDescription
StoreProviderElementTypeThe React Context Provider for the store.
useStore() => TA function to get the store context.

On this page

  • Introduction
  • API
    • Return
Edit this page on Github

Selected: