restructured elements slightly for better customization, updated readme and docs

This commit is contained in:
dswbx
2025-01-25 09:14:02 +01:00
parent f64e5dac03
commit cc76964d03
10 changed files with 211 additions and 40 deletions

View File

@@ -3,7 +3,7 @@ title: 'SDK (React)'
description: 'Use the bknd SDK for React'
---
bknd exports 4 useful hooks to work with your backend:
There are 4 useful hooks to work with your backend:
1. simple hooks which are solely based on the [API](/usage/sdk):
- [`useApi`](#useapi)
- [`useEntity`](#useentity)
@@ -11,6 +11,22 @@ bknd exports 4 useful hooks to work with your backend:
- [`useApiQuery`](#useapiquery)
- [`useEntityQuery`](#useentityquery)
## Setup
In order to use them, make sure you wrap your `<App />` inside `<ClientProvider />`, so that these hooks point to your bknd instance:
```tsx
import { ClientProvider } from "bknd/client";
export default function App() {
return <ClientProvider>
{/* your app */}
</ClientProvider>
}
```
For all other examples below, we'll assume that your app is wrapped inside the `ClientProvider`.
## `useApi()`
To use the simple hook that returns the Api, you can use:
```tsx