@cdr-kit/react/Hooks/useStoryClient
useStoryClient
Lazy-load and memoize a StoryClient from @story-protocol/core-sdk bound to the connected wagmi wallet. Returns undefined until the wallet connects and the lazy import resolves.
import { useStoryClient } from "@cdr-kit/react"
Signature
function useStoryClient(chainId?: number): StoryClient | undefined;Example
import { useStoryClient } from "@cdr-kit/react";
function Publish() {
const client = useStoryClient(); // bound to the connected wagmi wallet
if (!client) return <p>connect a wallet to publish</p>;
// client is the StoryClient from @story-protocol/core-sdk —
// pass it to useRegisterIp, useMintLicenseToken, etc.
return <RegisterButton client={client} />;
}Lazy-loaded peer dep
@cdr-kit/story is an optional peer dep on @cdr-kit/react — the hook does a dynamic import("@cdr-kit/story") on first call, so dashboards that never publish IP don't pay the bundle cost. If the peer dep isn't installed, the hook throws with a clear install hint.
Custom chain
The default chainId is 1315 (Story Aeneid). Pass an explicit value to bind the client to a different chain (e.g. Story mainnet once it ships).