Vanilla Client & React Wrapper
Which one should I use?
Vanilla Client vs React Wrapper
The Sage SDK provides two ways to integrate Sage Protocol functionality into your applications. Both approaches offer identical capabilities—the React wrapper is simply a convenience layer built on top of the vanilla client.
Vanilla Client
The vanilla client provides direct access to all Sage Protocol methods. It’s framework-agnostic and suitable for any JavaScript / TypeScript environment.
Setup:
Usage Pattern:
When to Use
- Non-React applications: Vue, Angular, Svelte, or vanilla JavaScript
- Server-side operations: Node.js backends or serverless functions
- Library integration: Building your own wrapper or abstraction layer
- Multiple clients: Applications that need multiple Sage client instances
React Wrapper
The React wrapper provides the same functionality through React hooks and context. It’s a thin convenience layer that makes integration cleaner in React applications.
Setup:
Usage Pattern:
When to Use
- React applications
Key Differences
Aspect | Vanilla Client | React Wrapper |
---|---|---|
Import | @sageprotocol/sdk/client | @sageprotocol/sdk/react |
Setup | Direct instantiation | Provider + hooks |
Methods | sageClient.methodName() | const { methodName } = useHook() |
Dependencies | None (beyond Sui) | React required |
Available Hooks
The React wrapper provides three hooks that correspond to the main functional areas:
Identical Functionality
Both approaches:
- Use the same transaction result pattern (
{ ok, err?, transaction? }
) - Require manual wallet integration for transaction signing
- Support the same networks (testnet/mainnet)
- Provide identical error handling and validation
- Offer the same performance characteristics
Implementation Notes
The React wrapper is a direct mapping—each hook method calls the corresponding vanilla client method with no additional processing, state management, or side effects. Choose based on your framework preference and application architecture.