@stakekit/api-hooks
TypeScript icon, indicating that this package has built-in type declarations

0.0.93 • Public • Published

React hooks for StakeKit API

Utility hooks for interacting with StakeKit API

npm install @stakekit/api-hooks

or

yarn add @stakekit/api-hooks

or

pnpm add @stakekit/api-hooks

Configure API client with proper base url, API key and wrap app with StakeKitQueryProvider:

Example:

import { APIManager, StakeKitQueryProvider, useStakeKitQueryClient } from '@stakekit/api-hooks';

APIManager.configure({
  apiKey: "<your-api-key-here>",
  baseURL: "<your-base-url-here>",
  queryClientConfig: { // optional
    defaultOptions: {
      queries: { cacheTime: 1000 * 30, staleTime: 1000 * 30 },
    },
  }
})

// APIManager.queryClient.clear()

const App = () => {
  const queryClient = useStakeKitQueryClient()

  const logout = () => queryClient.clear()

  return (
    <StakeKitQueryProvider>
      <Main />
      <button onClick={logout} />
    </StakeKitQueryProvider>
  )
}

After configuration part, hooks can be used

Readme

Keywords

Package Sidebar

Install

npm i @stakekit/api-hooks

Weekly Downloads

269

Version

0.0.93

License

MIT

Unpacked Size

665 kB

Total Files

11

Last publish

Collaborators

  • stefan_stakekit
  • notaphplover
  • philipmzdb
  • jdomingos
  • petar-omni