Skip to main content

Advanced

This guide covers patterns for developers who’ve built the basics and need custom hooks, server-side rendering support, or testing utilities.

Custom Hooks

Build reusable hooks that combine SDK functionality with application logic.

useDepositFlow

Encapsulates shield state management:

usePollingBalance

Auto-refresh balances on an interval:

SSR Support

The SDK uses WebAssembly, which requires special handling in server-side rendering environments.

Next.js App Router

Add WASM support to next.config.js:

Next.js Pages Router

Use dynamic imports to prevent server-side loading:

Hydration Mismatch Prevention

If you conditionally render based on auth state, use a client-only check:

Testing

Mock SDK

Create a mock SDK for unit tests:

Mock Provider

Wrap components in a test provider:

Testing useAuth

Testing useVault

Next Steps