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

1.2.31 • Public • Published

Scalar API Client React

Version Downloads License Discord

Installation

npm install @scalar/api-client-react

Usage

First we need to add the provider, you should add it in the highest place you have a unique spec.

import { ApiClientModalProvider } from '@scalar/api-client-react'

import '@scalar/api-client-react/style.css'
;<ApiClientModalProvider
  configuration={{
    url: 'https://cdn.jsdelivr.net/npm/@scalar/galaxy/dist/latest.json',
  }}>
  {children}
</ApiClientModalProvider>

Then you can trigger it from anywhere inside of that provider by calling the useApiClientModal()

import { useApiClientModal } from '@scalar/api-client-react'

const client = useApiClientModal()

return (
  <button onClick={() => client?.open({ path: '/auth/token', method: 'get' })}>
    Click me to open the Api Client
  </button>
)

Check out the playground for a working example.

Community

We are API nerds. You too? Let’s chat on Discord: https://discord.gg/scalar

License

The source code in this repository is licensed under MIT.

Package Sidebar

Install

npm i @scalar/api-client-react

Weekly Downloads

3,282

Version

1.2.31

License

MIT

Unpacked Size

252 kB

Total Files

14

Last publish

Collaborators

  • amritkahlon
  • cameronrohani
  • marclave
  • tommastro
  • scalar_geoff
  • hwkr
  • mason-little
  • hanspagel