Use this hook similar to useState hook. The difference is that you need to pass a unique key - unique across the app to make this state accessible to all client components.

const [state, setState] = useRGS<number>("counter", 1);
  • Type Parameters

    • T

    Parameters

    • key: string

      Unique key to identify the store.

    • Optionalvalue: ValueType<T>

      Initial value of the store.

    • Optionalplugins: Plugin<T>[]

      Plugins to be applied to the store.

    • doNotInit: boolean = false

      Do not initialize the store. Useful when you want to initialize the store later. Note that the setter function is not available until the store is initialized.

    Returns [T, SetStateAction<T>]

    • A tuple (Ordered sequance of values) containing the state and a function to set the state.