From 56db13407aa35d00b85ec2df042692edd4aea9da Mon Sep 17 00:00:00 2001 From: Michal Miszczyszyn Date: Fri, 15 Mar 2024 21:36:14 +0100 Subject: [PATCH] Update README --- README.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 33f73b6..e94e1d2 100644 --- a/README.md +++ b/README.md @@ -42,12 +42,14 @@ In order to use Saleor Auth SDK in React Server Components, the client needs to import { createSaleorAuthClient } from "@saleor/auth-sdk"; import { getNextServerCookiesStorage } from "@saleor/auth-sdk/next/server"; -const nextServerCookiesStorage = getNextServerCookiesStorage(); -const saleorAuthClient = createSaleorAuthClient({ - saleorApiUrl: "…", - refreshTokenStorage: nextServerCookiesStorage, - accessTokenStorage: nextServerCookiesStorage, -}); +const getServerAuthClient = () => { + const nextServerCookiesStorage = getNextServerCookiesStorage(); + returncreateSaleorAuthClient({ + saleorApiUrl: "…", + refreshTokenStorage: nextServerCookiesStorage, + accessTokenStorage: nextServerCookiesStorage, + }); +}; ``` Logging in can be implemented via Server Actions: @@ -58,7 +60,7 @@ Logging in can be implemented via Server Actions: action={async (formData) => { "use server"; - await saleorAuthClient.signIn( + await getServerAuthClient().signIn( { email: formData.get("email").toString(), password: formData.get("password").toString(), @@ -73,7 +75,7 @@ Logging in can be implemented via Server Actions: Then, you can use `saleorAuthClient.fetchWithAuth` directly for any queries and mutations. -For a full working example see the [Saleor Auth SDK example](https://github.com/saleor/example-auth-sdk/blob/5babda35969c35f423680b47d1446466b18b2461/app/ssr/page.tsx). +For a full working example, see the [Saleor Auth SDK example](https://github.com/saleor/example-auth-sdk/tree/app/ssr/page.tsx). ### Next.js Pages Router with [Apollo Client](https://www.apollographql.com/docs/react/)