docs(expo): remove $fetch api usage

This commit is contained in:
Bereket Engida
2025-04-13 00:30:11 +03:00
parent 2bbe85ae6f
commit c9fa76f9d1

View File

@@ -317,33 +317,7 @@ On native, the session data will be cached in SecureStore. This will allow you t
### Making Authenticated Requests to Your Server
To make authenticated requests to your server that require the user's session, you have two options:
1. Use the fetch client provided by Better Auth.
2. Retrieve the session cookie from `SecureStore` and manually add it to your request headers.
---
#### Option 1: Using the Fetch Client
Better Auth provides a built-in fetch client powered by [Better Fetch](http://better-fetch.vercel.app). This client automatically includes the session cookie in the headers of your requests.
```tsx
import { authClient } from "@/lib/auth-client";
const $fetch = authClient.$fetch;
// Example usage
$fetch("/api/secure-endpoint", {
method: "GET",
});
```
For more details, see the [Better Fetch documentation](http://better-fetch.vercel.app/docs).
#### Option 2: Adding the Cookie to Request Headers
If you prefer using your own fetch client, you can retrieve the session cookie stored in the device using `authClient.getCookie` and manually add it to your request headers.
To make authenticated requests to your server that require the user's session, you have to retrieve the session cookie from `SecureStore` and manually add it to your request headers.
```tsx
import { authClient } from "@/lib/auth-client";