Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
mmiszy committed Mar 15, 2024
1 parent 03a9ed0 commit 56db134
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions README.md
Expand Up @@ -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:
Expand All @@ -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(),
Expand All @@ -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/)

Expand Down

0 comments on commit 56db134

Please sign in to comment.