Skip to content

Commit 56db134

Browse files
committed
Update README
1 parent 03a9ed0 commit 56db134

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,14 @@ In order to use Saleor Auth SDK in React Server Components, the client needs to
4242
import { createSaleorAuthClient } from "@saleor/auth-sdk";
4343
import { getNextServerCookiesStorage } from "@saleor/auth-sdk/next/server";
4444

45-
const nextServerCookiesStorage = getNextServerCookiesStorage();
46-
const saleorAuthClient = createSaleorAuthClient({
47-
saleorApiUrl: "",
48-
refreshTokenStorage: nextServerCookiesStorage,
49-
accessTokenStorage: nextServerCookiesStorage,
50-
});
45+
const getServerAuthClient = () => {
46+
const nextServerCookiesStorage = getNextServerCookiesStorage();
47+
returncreateSaleorAuthClient({
48+
saleorApiUrl: "",
49+
refreshTokenStorage: nextServerCookiesStorage,
50+
accessTokenStorage: nextServerCookiesStorage,
51+
});
52+
};
5153
```
5254

5355
Logging in can be implemented via Server Actions:
@@ -58,7 +60,7 @@ Logging in can be implemented via Server Actions:
5860
action={async (formData) => {
5961
"use server";
6062

61-
await saleorAuthClient.signIn(
63+
await getServerAuthClient().signIn(
6264
{
6365
email: formData.get("email").toString(),
6466
password: formData.get("password").toString(),
@@ -73,7 +75,7 @@ Logging in can be implemented via Server Actions:
7375

7476
Then, you can use `saleorAuthClient.fetchWithAuth` directly for any queries and mutations.
7577

76-
For a full working example see the [Saleor Auth SDK example](https://github.com/saleor/example-auth-sdk/blob/5babda35969c35f423680b47d1446466b18b2461/app/ssr/page.tsx).
78+
For a full working example, see the [Saleor Auth SDK example](https://github.com/saleor/example-auth-sdk/tree/app/ssr/page.tsx).
7779

7880
### Next.js Pages Router with [Apollo Client](https://www.apollographql.com/docs/react/)
7981

0 commit comments

Comments
 (0)