@shopify/shop-minis-react
Version:
React component library for Shopify Shop Minis with Tailwind CSS v4 support (source-only, requires TypeScript)
30 lines (25 loc) • 817 B
text/typescript
import {SetSecretParams} from '@shopify/shop-minis-platform/actions'
import {useHandleAction} from '../../internal/useHandleAction'
import {useShopActions} from '../../internal/useShopActions'
interface UseSecureStorageReturns {
/**
* Get the secret from the secure storage.
*/
getSecret: () => Promise<string | null>
/**
* Set a secret in the secure storage.
*/
setSecret: (params: SetSecretParams) => Promise<void>
/**
* Remove the secret from the secure storage.
*/
removeSecret: () => Promise<void>
}
export function useSecureStorage(): UseSecureStorageReturns {
const {getSecret, setSecret, removeSecret} = useShopActions()
return {
getSecret: useHandleAction(getSecret),
setSecret: useHandleAction(setSecret),
removeSecret: useHandleAction(removeSecret),
}
}