React Hooks Reference
SafeProvider

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.


_22
import ReactDOM from 'react-dom/client'
_22
import { createConfig, SafeProvider } from '@safe-global/safe-react-hooks'
_22
import { sepolia } from 'viem/chains'
_22
import App from './App.tsx'
_22
_22
const config = createConfig({
_22
chain: sepolia,
_22
provider,
_22
signer,
_22
safeOptions: {
_22
owners: ['0x...', '0x...', '0x...'],
_22
threshold: 2
_22
}
_22
})
_22
_22
const root = document.getElementById('root')
_22
_22
ReactDOM.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.

Was this page helpful?