Advanced Usage
This guide covers advanced SDK features for power users.Custom Endpoint
The hooks and query functions call/api/daocafe on the current origin (see
Server Handler). Point them somewhere else if your handler lives
on another path or host.
Changing the Default Endpoint
Creating a Custom Client
Modifying Default Client Headers
Refreshing After Transactions
The server answers from a cache that re-syncs every 15 seconds. After a transaction is mined, userefreshDaoCafe so the user sees their change right away:
markFresh() before invalidating.
Cache Invalidation
When using React hooks with TanStack Query, you can invalidate cached data to trigger refetches.Basic Invalidation
Targeted Invalidation
Invalidate only specific queries for better performance:Query Key Reference
Error Handling
With React Hooks
TanStack Query provides built-in error handling:With Query Functions
Use try/catch for promise-based functions:Common Error Types
Retry Configuration
Configure TanStack Query’s retry behavior:Tree-Shaking
The SDK is designed for optimal bundle sizes. Only import what you need:Bundle Size Tips
- Import specific hooks instead of entire modules
- Use
typeimports for TypeScript types - React hooks are optional - if you don’t import them, they’re not bundled