React SDK
Use Carpo services from a React application.
The React SDK combines the Carpo browser clients with a provider and TanStack Query hooks. Authentication and service requests use the Project Auth session by default. Database and Storage requests still pass through the Carpo API, where environment permissions and policies are checked.
A typical setup
- Create one
CarpoClientfor a project, database, and environment. - Place
QueryClientProvideraboveCarpoProviderin your component tree. - Use the native Better Auth client for sign in and session state.
- Use SDK hooks for cached Database and Storage reads, mutations, and realtime invalidation.
Modules
| Module | What it provides |
|---|---|
auth | Better Auth React client with Carpo Project Auth plugins |
database | Typed table reads and writes through the policy checked Data API |
realtime | Authorized table change invalidations over one WebSocket per client |
functions | Fetch compatible calls to deployed Functions |
storage | Policy checked object operations and signed R2 transfers |
react | CarpoProvider, context hooks, and TanStack Query hooks |
Guides
Initialize the client
Add the shared provider and configure an environment.
Database access
Read and write rows with table scoped types.
Storage
Configure access policies and transfer objects.
Choose a server client for trusted backend work or to retain an incoming user's identity during server requests.