Hooks
useInjectedConnectors
useInjectedConnectors
Hook for discovering injected connectors.
Usage
_33import {_33 StarknetConfig,_33 publicProvider,_33 argent,_33 braavos,_33 useInjectedConnectors,_33} from "@starknet-react/core";_33_33export default function App({ children }) {_33 const chains = [goerli, mainnet];_33 const providers = [publicProvider()];_33 const { connectors } = useInjectedConnectors({_33 // Show these connectors if the user has no connector installed._33 recommended: [_33 argent(),_33 braavos(),_33 ],_33 // Hide recommended connectors if the user has any connector installed._33 includeRecommended: "onlyIfNoConnectors",_33 // Randomize the order of the connectors._33 order: "random"_33 });_33_33 return (_33 <StarknetConfig_33 chains={chains}_33 providers={providers}_33 connectors={connectors}_33 >_33 {children}_33 </StarknetConfig>_33 );_33}
Options
-
recommended?: Connector[]
- List of recommended connectors.
-
includeRecommended?: "always" | "onlyIfNoConnectors"
- If
"always"
, the hook always returns the recommended connectors. - If
"onlyIfNoConnectors"
, the recommended connectors are included only if no other connector is installed.
- If
-
order?: "random" | "alphabetical"
- Control the order in which connectors are returned.
- If
"random"
, connectors are shuffled. - If
"alphabetical"
, connectors are alphabetically sorted by their id.
Returns
connectors: Connector[]
- Contains the list of injected connectors installed by the user.
- All connectors are unique and sorted.