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.

    Returns [T, SetStateAction<T>]

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