@teamkeel/client-react
TypeScript icon, indicating that this package has built-in type declarations

0.380.3 • Public • Published

@teamkeel/client-react

Create a fully typed useKeel() hook from a generated Keel client.

Install

npm i @teamkeel/client-react

Usage

Create the KeelProvider and useKeel components by passing your generated APIClient into the keel function from this package.

N.B. See here for documentation on generating a client

import { APIClient } from "../keelClient";
import { keel } from "@teamkeel/client-react";
export const { KeelProvider, useKeel } = keel(APIClient);

Wrap your app with the exported KeelProvider and set the endpoint for you API.

The endpoint is the base URL + the api name (if you haven't manually set an API name this is api). This url can be found in the Keel web console or in the output of keel run in your terminal.

<KeelProvider endpoint="https://myproject.keelapps.xyz/api/">
	<App />
</KeelProvider>

Now you can use the typed useKeel hook in any component within your app. You can read more here on how to use the client.

function MyComponent() {
	const keel = useKeel();
}

Readme

Keywords

none

Package Sidebar

Install

npm i @teamkeel/client-react

Weekly Downloads

74

Version

0.380.3

License

ASL (Apache 2.0)

Unpacked Size

7.32 kB

Total Files

6

Last publish

Collaborators

  • teamkeel