Home > @shopware-pwa/composables > useSharedState

# useSharedState() function

Replacement for Vuex. Composable, which enables you to use shared state in your application. State is shared both on server and client side.

Signature:

export declare function useSharedState(): {
    sharedRef: <T>(uniqueKey: string, defaultValue?: T | undefined) => WritableComputedRef<T | null>;
    preloadRef: (refObject: Ref<unknown>, callback: () => Promise<void>) => Promise<void>;
};

Returns:

{ sharedRef: <T>(uniqueKey: string, defaultValue?: T | undefined) => WritableComputedRef<T | null>; preloadRef: (refObject: Ref<unknown>, callback: () => Promise<void>) => Promise<void>; }