SafeProvider
The SafeProvider
is a context provider (opens in a new tab) that wraps a React application and makes all the Safe React Hooks available within the application with a global configuration.
Usage
Any component that uses a Safe React Hook requires a SafeProvider
to be present somewhere in its parent component tree.
_22import ReactDOM from 'react-dom/client'_22import { createConfig, SafeProvider } from '@safe-global/safe-react-hooks'_22import { sepolia } from 'viem/chains'_22import App from './App.tsx'_22_22const config = createConfig({_22 chain: sepolia,_22 provider,_22 signer,_22 safeOptions: {_22 owners: ['0x...', '0x...', '0x...'],_22 threshold: 2_22 }_22})_22_22const root = document.getElementById('root')_22_22ReactDOM.createRoot(root).render(_22 <SafeProvider config={config}>_22 <App />_22 </SafeProvider>_22)
Parameters
config
- Type:
SafeConfig
The configuration object required to connect and setup a Safe account in the application.
Use the createConfig
function to create the configuration object.