@teamkeel/client-react-query
v0.428.2
Published
Typed React-Query Hooks for Keel clients
Readme
@teamkeel/client-react-query
Create fully typed React-Query hooks from a generated Keel client.
Install
N.B. Requires @teamtkeel/client-react to be installed and setup first.
npm i @teamkeel/client-react-queryUsage
Create and export the useKeelQuery and useKeelMutation hooks by passing in a useKeel hook generated by the client-react package.
// Follow @teamtkeel/client-react setup instructions
import { APIClient } from "../keelClient";
import { keel } from "@teamkeel/client-react";
import { keelQuery } from "@teamkeel/client-react-query";
export const { KeelProvider, useKeel } = keel(APIClient);
export const { useKeelQuery, useKeelMutation } = keelQuery(useKeel);
You can then use these hooks in your components. Inputs are fully typed based on the action name.
const query = useKeelQuery("actionName", actionInputs, queryOptions);
const mutation = useKeelMutation("actionName", mutationOptions);
