The react-sdk is a library that provides a set of hooks to interact with the SDK. It is designed to be used in a React application.
- Install the dependencies
pnpm install
- Update the
@story-protocol/core-sdk
package version in thepackages/react-sdk/package.json
file to the latest version.
Important: Once publish core-sdk, you need to update the core-sdk version in the react-sdk package.json file.
- Generate the SDK
pnpm run generate
This SDK is generated using the command pnpm run generate
. The source code resides in the packages/sdk
directory and the generated SDK can be found in the packages/react-sdk
folder.
- Install Story Protocol React SDK
pnpm install @story-protocol/react-sdk
- Import the provider in your React application
import { StoryProvider } from "@story-protocol/react-sdk";
const client = StoryClient.newClient(config);
<StoryProvider
config={{
chainId: "sepolia",
transport: http("RPC_URL"),
wallet: walletClient,
}}
</StoryProvider>
- Use the hooks in your component
import { useIpAsset } from "@story-protocol/react-sdk";
const { data, error, loading, register } = useIpAsset();
register({ nftContract: "0x1234", tokenId: "1" });
- Install yalc
npm install -g yalc
- For manual testing of the react-sdk, set up a separate web project. The guide below uses
yalc
to link thereact-sdk
locally, enabling its installation and import for testing.
Under the typescript-sdk/packages/react-sdk
directory:
-
Execute
npm run build
to build your latest code. -
Run
yalc publish
. You should see a message like@story-protocol/react-sdk@<version> published in store.
(Note: The version number may vary). -
To set up your testing environment (e.g., a new Next.js project), use
yalc add @story-protocol/react-sdk@<version>
(ensure the version number is updated accordingly). -
Run
pnpm install
. This installs@story-protocol/react-sdk@<version>
with your local changes.
Under the typescript-sdk/packages/react-sdk
directory:
- Execute
npm run build
to build your latest code. - Run
yalc push
.
In your testing environment:
- Run
yalc update
to pull the latest changes.