React SDK
Installation
To install the React SDK, use your preferred package manager from the command line. For example, if you use bun, execute the following command:
bun add @inverter-network/react wagmi@^2.14.11 viem@^2.24.2 @tanstack/react-query@^5.59.0
Initializing the React SDK
Since our React SDK uses @tanstack/react-query
, wagmi
and viem
we need these instances to be present at the parent level.
@inverter-network/react
SDK has the export paths @inverter-network/react
and @inverter-network/react/client
Client components and hooks are exported from */client
this is done to ensure Next.js
users have a separate import path for server components .
'use client'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { getERPCTransport } from '@inverter-network/sdk'
import { WagmiProvider, createConfig, http } from 'wagmi'
import { sepolia } from 'viem/chains'
const chains = [sepolia]
const queryClient = new QueryClient()
const wagmiConfig = createConfig({
chains,
multiInjectedProviderDiscovery: false,
transports: {
[sepolia.id]: getERPCTransport(sepolia.id),
},
ssr: true, // If the user is using a SSR supporting framework
cacheTime: 5000, // 5 seconds
})
export function Providers({ children }: { children: React.ReactNode }) {
return (
<QueryClientProvider client={queryClient}>
<WagmiProvider config={wagmiConfig} reconnectOnMount>
{children}
</WagmiProvider>
</QueryClientProvider>
)
}
Last updated