useConfig
The useConfig
hook provides access to the current LunoKit configuration, including chains, connectors, and other settings.
Import
tsx
import { useConfig } from '@luno-kit/react'
Usage
Basic Usage
tsx
import { useConfig } from '@luno-kit/react'
function ConfigInfo() {
const config = useConfig()
if (!config) {
return <div>No configuration available</div>
}
console.log('config: ', config)
return (
<div>
<h3>Configuration</h3>
</div>
)
}
ts
import { createConfig, kusama, polkadot, polkadotjsConnector } from '@luno-kit/react'
const config = createConfig({
appName: 'luno with-vite example',
chains: [polkadot, kusama],
connectors: [polkadotjsConnector()],
autoConnect: true,
});
Return Value
The hook returns a Config
object or undefined
:
Property | Type | Description |
---|---|---|
config | Config | undefined | The current LunoKit configuration |
Related Types
Config
tsx
interface Config extends LunoApiOptions {
readonly appName: string; // Application name
readonly chains: readonly Chain[]; // Available chains
readonly connectors: readonly Connector[]; // Available wallet connectors
readonly transports: Readonly<Record<string, Transport>>; // Transport configurations
readonly storage: LunoStorage; // Storage interface
readonly autoConnect: boolean; // Whether to auto-connect on mount
}
LunoStorage
tsx
interface LunoStorage {
getItem(keySuffix: string): Promise<string | null>; // Get item from storage
setItem(keySuffix: string, value: string): Promise<void>; // Set item in storage
removeItem(keySuffix: string): Promise<void>; // Remove item from storage
}
TIP
This hook provides read-only access to the configuration that was passed to LunoKitProvider
.
Related Hooks
useChain
- Get current chain informationuseConnectors
- Get available connectorsuseApi
- Access the chain API client