diff --git a/README.md b/README.md index 842abdd..099f0cc 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,6 @@ The authentication occurs in the React component lifecycle by setting the event ```javascript const { saleorAuthClient, isAuthenticating } = useSaleorAuthClient({ saleorApiUrl: "https://master.staging.saleor.cloud", - storage: window.localStorage, }); ``` @@ -164,10 +163,7 @@ useAuthChange({ export const App = () => { const { saleorApiUrl } = getQueryParams(); const { locale, messages } = useLocale(); - const saleorAuthClientProps = useSaleorAuthClient({ - saleorApiUrl, - storage: localStorage, - }); + const saleorAuthClientProps = useSaleorAuthClient({ saleorApiUrl }); const { saleorAuthClient } = saleorAuthClientProps; @@ -213,10 +209,7 @@ useAuthChange({ ```jsx export const App = () => { const { saleorApiUrl } = getQueryParams(); - const saleorAuthClientProps = useSaleorAuthClient({ - saleorApiUrl, - storage: localStorage, - }); + const saleorAuthClientProps = useSaleorAuthClient({ saleorApiUrl }); const { saleorAuthClient } = saleorAuthClientProps; diff --git a/src/SaleorAuthClient.ts b/src/SaleorAuthClient.ts index 4aa94c2..5fd7120 100644 --- a/src/SaleorAuthClient.ts +++ b/src/SaleorAuthClient.ts @@ -16,7 +16,7 @@ import { CHECKOUT_CUSTOMER_DETACH, PASSWORD_RESET, TOKEN_CREATE, TOKEN_REFRESH } export interface SaleorAuthClientProps { onAuthRefresh?: (isAuthenticating: boolean) => void; saleorApiUrl: string; - storage: Storage | undefined; + storage?: Storage; } export class SaleorAuthClient { diff --git a/src/react/useSaleorAuthClient.ts b/src/react/useSaleorAuthClient.ts index 82d69be..deec4d8 100644 --- a/src/react/useSaleorAuthClient.ts +++ b/src/react/useSaleorAuthClient.ts @@ -12,7 +12,7 @@ export interface UseSaleorAuthClient { */ export const useSaleorAuthClient = ({ saleorApiUrl, - storage, + storage = typeof window !== "undefined" ? window.localStorage : undefined, onAuthRefresh, }: SaleorAuthClientProps): UseSaleorAuthClient => { const [isAuthenticating, setIsAuthenticating] = useState(false);