Scalar API Client React
Installation
npm install @scalar/api-reference-react
Usage
import { ApiReferenceReact } from '@scalar/api-reference-react'
import React from 'react'
function App() {
return (
<ApiReferenceReact
configuration={{
spec: {
url: 'https://petstore.swagger.io/v2/swagger.json',
},
}}
/>
)
}
export default App
Example
You can find an example in this repo under examples/react
Props
ApiReference only takes one prop which is the configuration object.
configuration: ReferenceProps
You can find the full configuration options under
packages/api-reference.
Here are the type definitions:
export type ReferenceProps = {
configuration?: {
theme?: ThemeId
layout?: ReferenceLayoutType
spec?: {
url?: string
content?: string | Record<string, any> | (() => Record<string, any>)
}
proxy?: string
isEditable?: boolean
showSidebar?: boolean
darkMode?: boolean
searchHotKey?:
| 'a'
| 'b'
| 'c'
| 'd'
| 'e'
| 'f'
| 'g'
| 'h'
| 'i'
| 'j'
| 'k'
| 'l'
| 'm'
| 'n'
| 'o'
| 'p'
| 'q'
| 'r'
| 's'
| 't'
| 'u'
| 'v'
| 'w'
| 'x'
| 'y'
| 'z'
metaData?: MetaFlatInput
hiddenClients?: string[]
customCss?: string
onSpecUpdate?: (spec: string) => void
authentication?: Partial<AuthenticationState>
}
}