@teamkeel/client-react-query
v0.396.8
Published
Typed React-Query Hooks for Keel clients
Downloads
897
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-query
Usage
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);